2013年10月19日

作业3-6 查询水果的单价

摘要: #includeint main(void){ int choice,i; double price; for(i=1;i<=5;i++){ printf("[1] Select apples \n"); printf("[2] Select pears \n"); printf("[3] Select oranges \n"); printf("[4] Select grapes \n"); printf("[0] exit \n"); printf("Enter choice 阅读全文

posted @ 2013-10-19 22:51 大叔控727 阅读(472) 评论(0) 推荐(0) 编辑

作业3-5 输入五级制成绩(A-E),输出相应的百分制成绩(0-100)区间,要求使用 switch语句

摘要: #includeint main(void){ char ch; printf("Input Grade: "); ch=getchar(); switch(ch){ case 'A': printf("%c 90-100\n",ch); break; case 'B': printf("%c 80-89\n",ch); break; case 'C': printf("%c 70-79\n",ch); ... 阅读全文

posted @ 2013-10-19 22:50 大叔控727 阅读(686) 评论(0) 推荐(0) 编辑

作业3-3 输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数

摘要: #includeint main(void){ int yinwen,shuzi,koge,other; char ch; int i; yinwen=shuzi=koge=other=0; printf("Enter 15 characters:"); for(i=1;i='a'&&ch='A'&&ch='0'&&ch=' '&&ch<='\n') koge++; else other++; } printf("y 阅读全文

posted @ 2013-10-19 22:48 大叔控727 阅读(1428) 评论(0) 推荐(0) 编辑

作业3-2 输入一个正整数 n,再输入 n 个学生的成绩,计算平均成绩,并统计所有及格学生的人数。

摘要: #includeint main(void){ int n,m; double grade,total; n=0; m=0; total=0; printf("Enter grades:"); scanf_s("%lf",&grade); while(grade>=0){ total=total+grade; m++; if(grade<60) n++; scanf_s("%lf",&grade); } if(m!=0){ printf("Gr... 阅读全文

posted @ 2013-10-19 22:47 大叔控727 阅读(452) 评论(0) 推荐(0) 编辑

作业3-4 循环输入多个年份 year,判断该年是否为闰年。判断闰年的条件是:能被 4 整除但不能被100 整除,或者能被 400 整除。输入-1退出程序执行

摘要: #includeint main(void){ int i,n,year; printf("Enter n:"); scanf_s("%d",&n); for(i=1;i<=n;i++){ printf("Enter year:"); scanf_s("%d",&year); if((year%4==0&&year%100!=0)||(year%400==0)){ printf("这是闰年"); } else{ printf("这不是闰年" 阅读全文

posted @ 2013-10-19 22:47 大叔控727 阅读(983) 评论(0) 推荐(0) 编辑

作业3-1 输入一个整数 x,计算并输出下列分段函数 sign(x) 的值

摘要: #includeint main(void){ int x,y; printf("Enter x:\n"); scanf_s("%d",&x); if(x<0){ y = -1; } else if(x==0){ y=0; } else{ y=1; } printf("y=%d\n",y); return 0;} 阅读全文

posted @ 2013-10-19 22:44 大叔控727 阅读(2417) 评论(0) 推荐(0) 编辑

习题2-8

摘要: #include int main(void) { int i,n; double x; double fact(int n); scanf_s("%d", &n); x=0; for(i=0;i<=n;i++){ x=x+fact(i); } printf("x=%.0f\n",x); return 0;}double fact(int n) { int i; double y; y=1; for(i=1;i<=n;i++){ y=... 阅读全文

posted @ 2013-10-19 22:28 大叔控727 阅读(72) 评论(0) 推荐(0) 编辑

习题2-7

摘要: #include #include int main(void) { int i,n; double x; scanf("%d",&n); x=0; for(i=1;i<=n;i++){ x=x+powl(2,i); } printf("x=%.0f\n",x); return 0; 阅读全文

posted @ 2013-10-19 22:27 大叔控727 阅读(84) 评论(0) 推荐(0) 编辑

习题2-5

摘要: #includeint main(void){ int i,n,numerator,denominator,flag; double sum,item; printf("Enter n:"); scanf("%d",&n); numerator=1; denominator=1; sum=0; flag=1; for(i=1;i<=n;i++){ item=flag*(numerator*1.0/denominator); numerator=numerator+1; denominator... 阅读全文

posted @ 2013-10-19 22:23 大叔控727 阅读(57) 评论(0) 推荐(0) 编辑

习题2=6

摘要: #include #include int main(void) { int year; double loan,money,my,rate; scanf("%Lf",&loan); scanf("%Lf",&rate); printf("year money\n"); for(year=5;year<=30;year++){ my=pow(1+rate,12*year); money=loan*rate*my/(my-1); printf("year=%d money=%.0f\n",yea 阅读全文

posted @ 2013-10-19 22:22 大叔控727 阅读(58) 评论(0) 推荐(0) 编辑

习题2-4

摘要: #includeint main(void){ int x,y,m,n,i; double h; printf("Enter m,n:"); scanf("%d%d",&m,&n); if(m>n){x=m;y=n;} else{x=n;y=m;} h=0.00; for(i=y;i<=x;i++){ h=h+i*i+1/i; } printf("h=%.2lf",h); return 0;} 阅读全文

posted @ 2013-10-19 22:20 大叔控727 阅读(53) 评论(0) 推荐(0) 编辑

习题2-3

摘要: #includeint main(void){ int n,i; double x,y; y=1; printf("输入n,x:"); scanf("%d%Lf",&n,&x); for(i=1;i<=n;i++){ y=y*x; } printf("y=%Lf",y); return 0;} 阅读全文

posted @ 2013-10-19 22:18 大叔控727 阅读(76) 评论(0) 推荐(0) 编辑

习题2-1

摘要: #includeint main(void){ int num1,num2,a; scanf("%d%d",&num1,&num2); a=num1-num2; printf("%d\n",a); return 0;}#includeint main(void){ int num1,num2,a; scanf("%d%d",&num1,&num2); a=num1*num2; printf("%d\n",a); return 0;}#includeint main(void){ in 阅读全文

posted @ 2013-10-19 22:17 大叔控727 阅读(84) 评论(0) 推荐(0) 编辑

导航