摘要: /* 求解简单的四则运算表达式 */#includeint main(void){ double value1,value2; char op; printf("Type in an expression:"); scanf("%lf%c%lf",&value1,&op,&value2); if(op=='+') printf("=%.2f\n",value1+value2); else if(op=='-') printf("=%.2f\n",value1- 阅读全文
posted @ 2013-10-02 22:45 刘睿1994 阅读(113) 评论(0) 推荐(0) 编辑
摘要: /* 计算多分段函数 */#includeint main(void){ double x,y; printf("Enter x:"); scanf_s("%lf",&x); if(x<0){ y=0; } else if(x<=15){ y=4*x/3; } else{ y=2.5*x-10.5; } printf("f(%.2f)=%.2f\n",x,y); return 0;} 阅读全文
posted @ 2013-10-02 22:39 刘睿1994 阅读(87) 评论(0) 推荐(0) 编辑
摘要: /* 输入一批学生的成绩,计算平均分,并统计不及格成绩的学生人数 */#includeint main(void){ int count,i,n; double grade,total; printf("Enter n:"); scanf_s("%d",&n); total=0; count=0; for(i=1;i<=n;i++){ printf("Enter grade#%d:",i); scanf_s("%lf",&grade); total=total+grade; if(grade& 阅读全文
posted @ 2013-10-02 22:34 刘睿1994 阅读(89) 评论(0) 推荐(0) 编辑
摘要: /* 判断整数的奇偶性 */#includeint main(void){ int number; printf("Enter a number:"); scanf_s("%d",&number); if(number%2==0){ printf("The number is even.\n"); } else{ printf("The number is odd.\n"); } return 0;} 阅读全文
posted @ 2013-10-02 22:31 刘睿1994 阅读(71) 评论(0) 推荐(0) 编辑
摘要: /* 简单猜数游戏 */#includeint main(void){ int mynumber=38; int yournumber; printf("Input your number:"); scanf_s("%d",&yournumber); if(yournumber==mynumber) printf("Ok!you are right!\n"); else if(yournumber>mynumber) printf("Sorry!your number is bigger than my n.. 阅读全文
posted @ 2013-10-02 22:27 刘睿1994 阅读(96) 评论(0) 推荐(0) 编辑