上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: /* 求解简单的四则运算表达式 */#includeint main(void){ double value1,value2; char op; printf("Type in an expression:"); scanf_s("%lf%clf",&value1,&op,&value2); switch(op){ case'+': printf("=%.2f\n",value1+value2); break; case'-': printf("=%.2f\n" 阅读全文
posted @ 2013-10-04 23:56 刘睿1994 阅读(103) 评论(0) 推荐(0) 编辑
摘要: /* 查询自动售货机中商品的价格 */#includeint main(void){ int choice,i; double price; for(i=1;i<=5;i++){ printf("[1]Select crisps\n"); printf("[2]Select popcorn\n"); printf("[3]Select chocolate\n"); printf("[4]Select cola\n"); printf("[0]Select exit\n"); printf( 阅读全文
posted @ 2013-10-04 23:49 刘睿1994 阅读(99) 评论(0) 推荐(0) 编辑
摘要: /* 统计字符,包括英文字母、数字字符和其他字符 */#includeint main(void){ int digit,letter,other; char ch; int i; digit=letter=other=0; printf("Enter 10 characters:"); for(i=1;i='a'&&ch='A'&&ch='0'&&ch<='9') digit++; else other++; } printf("letter=% 阅读全文
posted @ 2013-10-04 23:47 刘睿1994 阅读(114) 评论(0) 推荐(0) 编辑
摘要: /* 求解简单的四则运算表达式 */#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) 编辑
摘要: /* 定义和调用求阶乘函数生成阶乘表 */#includedouble fact(int n);int main(void){ int i,n; double result; printf("Enter n:"); scanf_s("%d",&n); for(i=0;i<=n;i++){ result=fact(i); printf("%d!=%.0f\n",i,result); } return 0;}double fact(int n){ int i; double product; produ... 阅读全文
posted @ 2013-10-01 16:21 刘睿1994 阅读(100) 评论(0) 推荐(0) 编辑
摘要: /* 调用幂函数pow()生成乘法表 */#include#includeint main(void){ int i,n; double power; printf("Enter n:"); scanf_s("%d",&n); for(i=0;i<=n;i++){ power=powl (2,i); printf("pow(2,%d)=%.0f\n",i,power); } return 0;} 阅读全文
posted @ 2013-10-01 16:17 刘睿1994 阅读(108) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 下一页