题目
有以下程序段#include <stdio.h>void fun(char*fname,char*st){ FILE * myf; int i; myf=fopen(fname,"w"); for(i=0;i<strlen(st);i++)fputc(st[i],myf); fclose(myf);}main(){ fun("test.t","new world"); fun("test.t","hello,");}程序执行后,文件test.t中的内容是A.hello, B.new worldhello,C.new world D.hello,rld
第1题
设文件test.txt中原已写入字符串Begin,执行以下程序后,文件中的内容为【 15 】 。
#include <stdio.h>
main()
{ FILE *fp;
fp= fopen("test.txt”, ”w+”);
fputs("test",fp);
fclose(fp);
}
第2题
以下程序中函数setup的功能是返回形参指针s1和s2所指字符串中较小字符串的首地址: # include<stdio. h> # include<string. h> char * scmp(char * s1, char * s2) { if(strcmp(s1, s2)<0) return(s1); else return(s2); } main() { int i; char string[20], str[3][20]; for(i=0; i<3; i++)gets(str[i]); strcpy(string, scmp(str[0], str[1])); strcpy(string, scmp(string, str[2])); printf("% s\n", string); } 若运行时依次输入:abcd、abba和abc3个字符串,则输出结果为______。
A.abcd
B.abba
C.abc
D.abca
第3题
有以下程序段:
include<iostream.h>
define MIN(x,y) (x)<(y)?(x):(y)
void main()
{
int i,j,K;
i=10;j=15;
k=10*MIN (i,j);
cout<<k<<endl;
}
程序执行后的输出结果是______。
第4题
有以下程序段
#include
main()
{ …
while(getchar()!='\n');
…
}
以下叙述中正确的是
A.此while语句将无限循环
B.getchar()不可以出现在while语句的条件表达式中
C.当执行此while语句时,只有按回车键程序才能继续执行
D.当执行此while语句时,按任意键程序就能继续执行
第5题
有以下程序段: #include<iostream.h> #define MAX(x,y)(x)>(y)?(x):(y) void main() { int i,j,k; i=10; j=15;k=MAX(i,j)*10; cout<<k<<end1; } 程序执行后的输出结果是()。
A.15
B.100
C.150
D.10
第6题
有以下程序段 #include<stdio.h> main() { . . .
while(getchar()!=\n); . . . } 以下叙述中正确的是()。
A.此while语句将无限循环
B.getchar()不可以出现在while语句的条件表达式中
C.当执行此while语句时,只有按回车键程序才能继续执行
D.当执行此while语句时,按任意键程序就能继续执行
第7题
(26)有以下程序段
#include <stdio.h>
main()
{ …
while(getchar()!='\n');
…
}
以下叙述中正确的是
A)此while语句将无限循环
B) getchar()不可以出现在while语句的条件表达式中
C)当执行此while语句时,只有按回车键程序才能继续执行
D)当执行此while语句时,按任意键程序就能继续执行
第8题
A.to
B.tomeet
C.toee
D.程序段不能通过编译
第9题
有以下程序段
#include<stdio.h>
main()
{
while(getchar()!=‘\n’);
}
以下叙述中正确的是
A.此while语句将无限循环
B.getchar()不可以出现在while语句的条件表达式中
C. 当执行此while语句时,只有按回车键程序才能继续执行
D.当执行此while语句时,按任意键程序就能继续执行
第10题
以下程序段有()处错误。 #include <iostream> using namespaces std; class Sample { private: int n; public: Sample (int i} { n=i; } void setvalue(int i) { n=i; } void display() { cout<<"n="<<n<<end1; } }; int main () { const Sample a(lO); a. setvalue (5)'; a.display(); return 0; }
A.1
B.2
C.3
D.4
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!