C语言编程题1.docVIP

  • 62
  • 0
  • 约 7页
  • 2017-08-25 发布于河南
  • 举报
编写一个程序,从键盘输入一个三位整数,将它们逆序输出。例如输入127,输出721。 参考答案 #include stdio.h main() { int num,a,b,c; printf(Please input the number:); scanf(%d,num); a=num/100; b=(num-100*a)/10; c=num-100*a-10*b; a += b*10+c*100; printf(The result is%d\n,a); } 打印出所有的“水仙花数”,所谓“水仙花数”是指一个3位数,其各位数字立方和等于该数本身。例如:153是一水仙花数,因为153=1^3+5^3+3^3. 参考答案 main() { int i,j,k,s; for(s=100;s=999;s++) { i=s/100; j=s/10-10; k=s-i*100-j*10; if(i*i*i+j*j*j+k*k*k==s) printf(s=%d\n,s); else continue; } } 编写一程序,对于给定的一个百分制成绩,输出相应的五分制成绩。设:90分以上为A,80~89分为B,70~79分为C,60~69分为D,60分以下为E。 参考答案 #includestdio.h main(){ int a,b; printf(Please input the score

文档评论(0)

1亿VIP精品文档

相关文档