C语言程序设计第8讲(2012级).pptVIP

  • 8
  • 0
  • 约6.63千字
  • 约 37页
  • 2017-09-19 发布于河南
  • 举报
第五章 循环结构程序设计 程序 : #include stdio.h void main() {char c; int letters=0,space=0,digit=0,others=0; printf(please input some characters\n); while((c=getchar())!=\n) {if(c=ac=z||c=Ac=Z) letters++; else if(c== ) space++; else if(c=0c=9) digit++; else others++;} printf(all in all:char=%d space=%d digit=%d others=%d\n,letters,space,digit,others);} 5.5 循环的嵌套 格式: goto 语句标号 ; ······ 标号:语句 ; 作用: 1)与 if 语句构成循环结构。 2)从循环体中强制退出。 5.6 goto语句和语句标号的使用 说明: 1)goto语句为无条件转向语句。 goto语句可以从循环体内跳出循环,尤其在多层循环中,使用goto语句可以跳到任意一层循环体内。 2)标号的命名规则同变量名。 3)goto语句不符合结构化程序设计原则,一般不主张使用。 5.6

文档评论(0)

1亿VIP精品文档

相关文档