题目
A.6
B.8
C.4
D.2
第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
第4题
若有以下程序: #include <iostream> using namespace std; int main() { int a=3; cout<<(a+=a-=a+A) <<end1; return 0; } 程序执行后的输出结果是()。
A.-6
B.12
C.0
D.-12
第5题
若有以下程序:
include <iostream>
using namespace std;
int main()
{
char str[10];
cin>>str;
cout<< str<<end1;
return 0;
}
当输入为:
This is a program!
那么执行程序后的输出结果是【 】。
第6题
若有以下程序: #include <iost ream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<", "; } }; class B { private:
A.10,10,10
B.10,12,14
C.8,10,12
D.8,12,10
第7题
若有以下程序: #include<iostream> using namespace Std; Class Base {public: Base() {x=0;} int x;}; class Derivedl:virtua1 public Base {public: Derived1() {x=10;}}; class Derived2:virtual1 public Base {public: Derived2()
A.20
B.30
C.10
D.0
第8题
若有以下程序段:
include <iostream>
using namespace std;
int main()
{
char*p="abcdefgh",*r;
long*q;
q=(long*)p;q++;
r=(char*)q;
cout<<r<<end1;
return 0;
}
该程序的输出结果是【 】。
第9题
若有以下程序: #include<stdio.h> int a[]={2,4,6,8}; main() { int i; int *p=a; for(i=0;i<4;i++) a[i]=*p; printf("%d\n",a[2]); } 上面程序的输出结果是()。
A.6
B.8
C.4
D.2
第10题
若有以下程序 #include <stdio.h> int a[]={2,4,6,8}; main() { int i; int *p=a; for(i=0;i<4;i++)a[i]=*p; printf("%d\n",a[2]);} 上面程序输出结果是
A.6
B.8
C.4
D.2
第11题
若有以下程序:
include <iostream>
using namespace std;
class Sample
{
private:
const int n;
public:
Sample(int i) :n(i) {)
void print()
{
cout<<"n="<<n<<end1;
}
};
int main()
{
sample a(10);
a.print();
return 0;
}
上述程序运行后的输出结果是【 】。
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!