- 博客(6)
- 收藏
- 关注
原创 6. 定义函数areaZ,功能是求圆锥体积。在主函数中输入半径r和高h,调用函数areaZ求体积,并在主函数中输出圆锥的体积,其中变量r,h均为double型数据。(公式v=h*3.14*r2/3)。
#include main() { }
2014-02-27 13:00:03
4185
原创 4.有一函数当x<0时y=1,当x>0时,y=3,当x=0时y=5,编程,从键盘输入一个x值,输出y值.
#include main() { float x; int y; printf("请输入一个数:\n",x); scanf("%f",x); if(x printf("y=%d",y=1); else if(x>0) printf("y=%d",y=3); else printf("y=%d",y=5); }
2014-02-27 12:44:59
2655
原创 3.编程序实现求1-1000之间的所有奇数的和并输出。
#include main() { int a,b,sum=0; for(a=1;a { b=a%2; if(b!=0) { sum+=a; } print("sum=%d\n",sum); } return 0; }
2014-02-19 15:50:45
8553
1
原创 2. 打印出所有的“水仙花数”,所谓“水仙花数”是指一个3位数,其各位数字立方和等于该数本身。例如:153是一水仙花数,因为153=1^3+5^3+3^3.
#include main() { int a,b,c,d; printf("Please input a three digit:\n",N); for(N=100;N { a=N/100; b=(N/10)%10; c=N%10%10; d=a*a*a+b*b*b+c*c*c; } if(d==N) { printf("The number is:%d/n",N);
2014-02-19 15:24:33
6005
1
原创 1 .设N是一个四位数,它的9倍恰好是其反序数(例如:123的反序数是321),求N的值。
#include main() { int a,b,c,d,M; printf("Please input a four digit:\n",N); for(N=1000;N { a=N/1000; b=(N/100)%10; c=(N/10)%100%10; d=N%1000%100%10; M=d*1000+c*100+b*10+a; } if(N*9==M) {
2014-02-19 15:11:50
5367
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅