习题解答-循环.pptVIP

  • 2
  • 0
  • 约7.99千字
  • 约 27页
  • 2018-05-08 发布于河南
  • 举报
习题解答-循环

第六章习题 循环结构程序设计 #includestdio.h void main() { int nl=0,nb=0,nd=0,no=0; char c; while((c=getchar())!=‘\n’) if(‘a’=cc=‘z’||‘A’=cc=‘Z’) nl++; else if(‘0’=cc=‘9’) nd++; else if(c==‘ ‘) nb++; else no++; printf(“%d Letters; %d blanks;”,nl,nb); printf(“%d Digits; %d other chars;”,nd,no); }//exe6-2 #includestdio.h void main() { long int n,a,t=0,i=0,sum=0,s=1; scanf(%ld%ld,a,n); for(i=1;i=n;i++) { t+=s*a; sum+=t; s*=10; } printf(%ld+%ld%ld+%ld%ld%ld+...(%ldth items)=%ld,a,a,a,a,a,a,n,sum); }//exe6-3 #includestdio.h void main() { long int n,t=1,i,s

文档评论(0)

1亿VIP精品文档

相关文档