【填空题】下面程序的功能是从键盘输入的10个整数中,找出第一个能被7整除的数。若找到,打印此数后退
下面程序由键盘输入字符,存放到文件中,用!结束输入,请在______[1]______上填空。 #include <stdio.h> main() { FILE *fp; char ch ; char fname[10]; printf(“Input name of file\n”); gets(fname); if ((fp=fopen( fname, “w”))==NULL) { printf (“cannot open file\n”); exit(0) ; } printf((“Enter data:\n”); while(_______[1]________!=’!’) //提示:从键盘输入一个字符,如不是! fputc(______[2]____________) ; //将从键盘输入的字符存入打开的文件中 fclose(fp); }
下面程序的功能是比较用户键盘输入的口令userInput与内设的口令password是否相同。若相同,则输出"Correct password! Welcome to the system...",若userInput <password,则输出"invalid password!user input> password"。 按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。 #include <stdio.h> #include <string.h> int main() { char password[7] = "secret"; char userInput[81] ; printf("Input Password:"); scanf(_____________); if ( ______________ ) printf("Correct password! Welcome to the system...\n"); else if ( ___________________) printf("Invalid password!user input <password\n"); else printf("invalid password!user input> password\n"); return 0; }
A、第8行: "%s", userInput 第9行: strcmp(userInput, password) == 0 第11行: strcmp(userInput, password) < 0
B、第8行: "%c", userInput 第9行: strcmp(userInput, password) = 0 第11行: strcmp(userInput, password) < 0
C、第8行: "%s", userInput 第9行: userInput==password 第11行: userInput <password>
D、第8行: "%c", userInput 第9行: strcpy(userInput, password) == 0 第11行: strcpy(userInput, password) < 0
本题程序的功能是从键盘上输入若干个学生的成绩,统计并输出最高成绩和最低成绩,当输入负数时结束输入。请将下述程序补充完整。(注意:不改动程序的结构,不得增行或删行。)
main()
{ float x,amax,amin;
scanf(“%f”,&x);
amax=x;
amin=x;
while(【1】)
{ if(x>amax) amax=x;
if(【2】) amin=x;
scanf(“%f”,&x);
}
printf(“\namax=%f\namin=%f\n”,amax,amin) ;
}
A.! a=b
B.a! =b
C.a= =b
D.a=b
include<stdio.h>
main()
{ int a[10],i;
for(i=0;i<10;++i)
scanf("%d",a[i]);
for(i=0;i<10;++i)
printf("%d",a[i]);
}
错误:______
改正:______
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!