上一页 1 2 3 4 5 6 7 ··· 11 下一页
摘要: //输入五级制成绩(A-E),输出相应的百分制成绩(0-100)区间,要求使用 switch语句。例如,输入 A,输出 90-100。五级制成绩对应的百分制成绩区间为:A(90-100)、B(80-89)、C(70-79)、D(60-69)和 E(0-59)。#includeint main(void){ char op; printf("输入五级制成绩:"); scanf("%c",&op); switch(op){ case'A':printf("grade=90-100"); break; case 阅读全文
posted @ 2013-10-20 16:39 plusfancy 阅读(90) 评论(0) 推荐(0) 编辑
摘要: //循环输入多个年份 year,判断该年是否为闰年。判断闰年的条件是:能被 4 整除但不能被100 整除,或者能被 400 整除。输入-1退出程序执行#includeint main(void){ int i,n,year; printf("Enter n:"); scanf("%d",&n); for(i=1;i<=n;i++){ printf("Enter year:"); scanf("%d",&year); if((year%4==0&&year%100!=0)||(y 阅读全文
posted @ 2013-10-20 16:07 plusfancy 阅读(80) 评论(0) 推荐(0) 编辑
摘要: //输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数#includeint main(void){ int digit,space,enter,letter,other; char ch; int i; digit=space=enter=letter=other=0; printf("Enter 15 characters:"); for(i=1;i='a'&&ch='A'&&ch='0'&&ch<='9') digit++; e 阅读全文
posted @ 2013-10-20 13:49 plusfancy 阅读(88) 评论(0) 推荐(0) 编辑
摘要: //输入一个正整数 n,再输入 n 个学生的成绩,计算平均成绩,并统计所有及格学生的人数。#includeint main (void){ int count,i,n; double grade,total; printf("Enter n:"); scanf("%d",&n); total=0; count=0; for(i=1;i=60){ count++; } }//输出 printf("Grade average=%.2f\n",total/n); printf("Number of fai... 阅读全文
posted @ 2013-10-20 01:41 plusfancy 阅读(102) 评论(0) 推荐(0) 编辑
摘要: //输入一个整数 x,计算并输出下列分段函数 sign(x) 的值#includeint main(void){ int x,y; printf("输入x:"); scanf("%d",&x); if(x<0){ y=-1; } else if(x==0){ y=0; } //运用if的语句 else{ y=1; } printf("y=%d",y); return 0;} 阅读全文
posted @ 2013-10-19 23:33 plusfancy 阅读(128) 评论(0) 推荐(0) 编辑
摘要: #include int main(void) { int i,n; double x; double fact(int n); scanf ("%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++){ ... 阅读全文
posted @ 2013-10-19 21:41 plusfancy 阅读(104) 评论(0) 推荐(0) 编辑
摘要: #include#includeint main(void){ int n,i,power; double product; printf("Enter n:"); scanf("%d",&n); product=0; for(i=1;i<=n;i++){ power=pow(2,i); printf("%d",power); product=product+power; } printf("product=%.0f\n",product); return 0;} 阅读全文
posted @ 2013-10-19 21:30 plusfancy 阅读(110) 评论(0) 推荐(0) 编辑
摘要: #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 21:09 plusfancy 阅读(104) 评论(0) 推荐(0) 编辑
摘要: #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 20:15 plusfancy 阅读(126) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int m,n; double i,y; y=1; printf("输入m,n的值:"); scanf("%d%d",&m,&n); for(i=m;i<=n;i++){ y=y+(i*i+1/i); } printf("y=%Lf",y); return 0;} 阅读全文
posted @ 2013-10-19 19:52 plusfancy 阅读(107) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 11 下一页