实验四选择结构(一) 答案.pptVIP

  • 11
  • 0
  • 约2.78千字
  • 约 14页
  • 2017-09-12 发布于河南
  • 举报
实验四选择结构(一) 答案

实验五 选择结构程序设计(一) 【实验目的】 1、了解C语言表示逻辑量的方法。 2、学会正确使用逻辑表达式和逻辑运算符。 3、熟练掌握if语句和if...else语句。 任务一:输入一个字母,如果是小写字母,就将其输出. #include stdio.h main() { char x; x=getchar(); if(x=‘a’x=‘z’) putchar(x); } 任务二:从键盘输入两个数,将大数放到x 中,小数放到y中,然后输出。。 #include stdio.h main() { int x,y,t; scanf(“%d%d”,x,y); if (xy) {t=x;x=y;y=t;} printf(“x=%d,y=%d\n”,x,y); } 任务三:输入三个整数,分别放在变量a、b、c中, 输入的数据重新按由小到大的顺序放在变量 a、b、c中,最后输出a、b、c的值。 #include stdio.h main() { int a,b,c,t; scanf(“%d%d%d”,a,b,c); if (ab) {t=a;a=b;b=t;} if (ac) {t=a;a=c;c=t;} if (bc) {t=b;b=c;c=t;} printf(

文档评论(0)

1亿VIP精品文档

相关文档