高级语言设计第四章程序.pptVIP

  • 3
  • 0
  • 约3.87千字
  • 约 48页
  • 2017-04-20 发布于湖北
  • 举报
第四章基本程序设计技术;4.1 统计(计数)问题;4.1 统计(计数)问题(续1);4.1 统计(计数)问题(续2);4.1 统计(计数)问题(续3);例2(教材例4.1):输入一行字符,统计其中的英文字母个数。提示:即输入若干字符,直到输入\n时停止输入 #include “stdio.h” void main() { char ch; int n=0; printf(“Input a string:\n”); while(1) { ch=getchar();if(ch==\n) break; if(ch=ach=z||ch=Ach=Z) n++; } printf(“Number of letters is %d.\n”,n); };4.2 求最大值与最小值;源程序1:/? 预置变量max初值为?2147483648 ?/ #include stdio.h void main() { long a,max=?2147483648; printf(Input long integers until input 0:\n); while(1) /*典型循环结构(一)*/ { scanf(%ld,a);if(!a) break; if(amax) max=a;

文档评论(0)

1亿VIP精品文档

相关文档