printf(“a!=b”);
}
3.程序填空。从键盘输入任意一个大写字母,将其转换成相应小写字母输出。
#include <stdio.h>
main()
{ char c;
scanf("%c",&c);
if (c>='A'&&c<='Z')或(c>=65&&c<=90)
c=c+32;
printf("\n%c",c);
}
4.有以下程序,执行后输出结果为_______4_______。
#include “stdio.h”
main( )
{ int a=1,b=2,c=3,d=4;
if(a<b<c) printf(“%d\n”,d);
else if((c-b)==a) printf(“%d\n”,2*d);
else printf(“%d\n”,4*d);
}
5.有以下程序,执行后输出结果为______9 7 0_____。
#include "stdio.h"
main( )
{ int a=8,b=7,c=9,t=0;
if(a<b) t=a;a=b;b=t;
if(a<c) t=a;a=c;c=t;
if(b<c) t=b;b=c;c=t;
printf("%5d%5d%5d\n",a,b,c);
}
6.有以下程序,执行后输出结果为_____9 8 7_____。
#include "stdio.h"
main( )
{ int a=8,b=7,c=9,t=0;
if(a<b) {t=a;a=b;b=t;}
if(a<c) {t=a;a=c;c=t;}
if(b<c) {t=b;b=c;c=t;}
printf("%5d%5d%5d\n",a,b,c);
}
7. x、y有如下函数关系,编写程序输入x,输出y值。 –1 (1≤x<10)
–11 (x≥10)
参考答案:
#include "stdio.h"
main()
{ double x,y;
scanf ("%lf",&x);
if (x<1)