C语言2011习题集(5)
时间:2025-07-11
时间:2025-07-11
printf("%f\n",(int)(x*1000+0.5)/(float)1000);
15 以下程序的功能是:输入一个小写字母,输出对应的大写字母,将程序补充完整。
main()
{ char ch;
scanf("%c",&ch); /* 从键盘输入一个小写字母 */ ch-=32; /* 将该字母转换为大写字母 */
printf("%c\n",ch); /* 输出转换后的结果 */
}
16 当运行以下程序时,在键盘上从第一列开始输入9876543210↙(此处↙代表回车),则
程序的输出结果是_a=98,b=765.000000,c=4321.000000__。 main()
{ int a; float b,c;
scanf("%2d%3f%4f",&a,&b,&c);
printf("\na=%d,b=%f,c=%f\n",a,b,c);
}
17 以下程序的运行结果是___。
main()
{ printf("%12.5f\n",123.1234567); 123.12346
printf("%12f\n",123.1234567); 123.123457
printf("%12.8d\n",12345); 00012345
printf("%12.8s\n","abcdefghij"); abcdefgh
}
18 运行以下程序时,如从键盘上输入abcdefg↙,则输出结果是_abc__。
main()
{ char ch1,ch2,ch3;
ch1=getchar(); ch2=getchar(); ch3=getchar(); putchar(ch1); putchar(ch2); putchar(ch3); putchar('\n');
}
19 运行以下程序时,如从键盘上输入:a=3,b=5↙35,35.12↙abc↙后,结果是_a=3,b=5,x=35.000000,y=35.119999,c1=a,c2=b__。
main()
{ int a,b; float x,y; char c1,c2;
scanf("a=%d,b=%d",&a,&b);
scanf("%f,%e",&x,&y);
scanf("%c%c%c",&c1,&c1,&c2);
printf("a=%d,b=%d,x=%f,y=%f,c1=%c,c2=%c\n",a,b,x,y,c1,c2); }
顺序、选择结构程序设计
一 单项选择题(每题2分,共40分) 1 以下程序运行后的输出结果是_B__。