正在加载图片...
C语言程序设计上机指导与同步训练 int x=-1 while(!x) printf(x=8dln”,x) 分析结果 运行结果 、完成程序 要求:根据要求,分析给出的上下语句,填写程序。 1.以下程序的功能是将从键盘输入的一对数,由小到大排序输出,当输入一对相等数 时结束循环,请在 上填写正确内容。 #include <stdio. h> main() [int a,b,t scanf("d影d",&a,sb); while i t=a; a=b; b=t: 1 printf("gd, gd\n",a, b) scanf("d暑d",&a,&b) 2.下面程序的功能是将小写字母变成对应大写字母后的第二个字母,其中y变成A 变成B,请在 上填写正确内容。 #include <stdio. h> char ch while(ch=getchar()I='\n) if(ch>='a’&&ch<=x’) else if (ch = 'y' printf(c”,ch) 3.以下程序功能是计算n!的值,请在 上填写正确内容 #include <stdio. h>·28· C 语言程序设计上机指导与同步训练 ·28· int x =-1; while(!x) x = x*x ; printf(“x=%d\n”,x); } 分析结果 运行结果 二、完成程序 要求:根据要求,分析给出的上下语句,填写程序。 1. 以下程序的功能是将从键盘输入的一对数,由小到大排序输出,当输入一对相等数 时结束循环,请在_______上填写正确内容。 #include <stdio.h> main() { int a,b,t; scanf("%d %d",&a,&b) ; while( ___________ ) { if (a>b) { t=a;a=b;b=t;} printf("%d,%d\n",a,b) ; scanf("%d %d",&a,&b) ; } } 2. 下面程序的功能是将小写字母变成对应大写字母后的第二个字母,其中 y 变成 A, z 变成 B,请在_______上填写正确内容。 #include <stdio.h> main() { char ch ; while(ch=getchar()!=’\n’) { if (ch >=‘a’ && ch<=‘x’) _____________________; else if (ch = ‘y’) __________________; else if (ch = ‘z’ ) ch = ‘B’ ; printf(“%c” ,ch); } } 3. 以下程序功能是计算 n! 的值,请在_______上填写正确内容。 #include <stdio.h> main() {
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有