C语言程序计经典必背程序.docVIP

  • 60
  • 0
  • 约7.43万字
  • 约 9页
  • 2016-12-14 发布于河南
  • 举报
C语言程序设计典型编程必背 1.计算机1-3+5-7+。。。-99+101的值 #includestdio.h main ( ) { int i,t=1,s; s=0; for(i=1;i=101;i+=2) { t=t*i; s=s+t;t=t0?-1:1; } printf(“%d\n”,s); } 2.输入一个十进制数,将他对应的二进制数的各位反序,形成新的十进制数输出。11—1011—1101—13 #includestdio.h main ( ) { int n,x,t; printf(“shuruzhengshu:”); scanf(“%d”,n); x=0; while(n!=0) { t=n%2; x=x*2+t;n=n/2; } printf(“xindezhengshu:%d\n,x”); } 3.给出年月日,计算出该日是该年的第几天。 #includestdio.h main ( ) { int year,month,day,days,i,d; printf(“shuru nian,yue,ri:”); scanf(“%d,%d,%d”,year,month,day); days=0; for(i=1;imonth;i++) {switch(i) {case 1: case 3: case 5: case 7: case 8: case 10: case

文档评论(0)

1亿VIP精品文档

相关文档