摘要: /* 6.9 10个学生,每个学生3门课程成绩,求平均分及前五名 */ #include "stdio.h"#include "conio.h"#define N 6 struct student /* 定义结构体数据类型 */{ int num; char name[10]; int score[3]; /* 不能使用float */ float average;}; voi... 阅读全文
posted @ 2008-04-19 20:45 emanlee 阅读(3115) 评论(1) 推荐(0) 编辑
摘要: /* 3.9 求派的值*/ #include "stdio.h" void main() { int n; double sum=0; for(n=1;n void main() { double i=1, s=1.0, t=1.0; do { t=t*(-1)*((2*i-1)/(2*i+1)); s=s+t; i++; }while (i void... 阅读全文
posted @ 2008-04-19 20:00 emanlee 阅读(4246) 评论(0) 推荐(0) 编辑
摘要: /* 3.6 求3个数中最大值。类似于例 1.2*/ #include void main( ) { int a, b, c, max; printf("\n 请输入3个整数,整数以空格分隔:\n"); scanf("%d%d%d",&a,&b,&c); if(a>b) max=a; else max=b; if(max void ... 阅读全文
posted @ 2008-04-19 19:58 emanlee 阅读(2195) 评论(0) 推荐(0) 编辑
摘要: /* 5.10 编写函数,求Fibonacci数列的第n项 */ #include "stdio.h"int fibonacci(int n); void main(){ int n; printf("求Fibonacci数列的第n项,请输入n\n"); scanf("%d", &n); /* VC6中n要小于 ? */ printf("Fibonacci数列的第%d项为... 阅读全文
posted @ 2008-04-19 19:39 emanlee 阅读(2456) 评论(0) 推荐(0) 编辑
摘要: /* 5.6 编写函数,输出所有水仙花数 */ #include "stdio.h"int isdaffodil( int n ) ; /* isdaffodil函数原型声明 */ void main(){ int i; for( i=100; i999 || n<100) return 0; /* it is not a daffodil */ units=n%10... 阅读全文
posted @ 2008-04-19 18:05 emanlee 阅读(5854) 评论(0) 推荐(0) 编辑