更多"若输入bcdefgh、m、abcdefg,以下程序的输出结果为( )"的相关试题:
[单项选择]若输入bcdefgh、m、abcdefg,以下程序的输出结果为( )。
#include<stdio.h>
#include<string.h>
main( )
int i;
char string[20],str[3][20];
for(i=0;i<3;i++)gets(str[i]);
if(strcmp(str[0],str[1])>0)
strcpy(string,str[0]);
else strcpy(string,str[1]);
if(strcmp(str[2],string)>0)
strcpy(string,str[2]);
printf("%s",string);
A. bcdefgh
B. m
C. abcdefg
D. bcdefgh或abcdefg
[单项选择]若输入“abcdef”、“abdef”,以下程序的输出结果为( )。
#include<stdio.h>
#lnclude<string.h>
main( )
int n;
char s1[20],s2[20],p1,*p2;
scanf("%s",s1);
scanf("%s",s2);
P1=s1;
p2=s2;
n=strcmp(p1,p2);
printf("%d/n",n);
A. -1
B. 0
C. "abcdef"
D. "abdef"
[简答题]
给出下面程序的输出结果
#include < iostream >
using namespace std;
template < class T >
T F(T x)
{
return x > 5;
}
void main( )
{
int a = 15;
cout << F(a) << " /n";
double b = - 5.8976;
cout << F(b) << " /n";
cout << F(5) <<" /n";
}
[简答题]
给出下面程序的输出结果
#include < iostream >
using namespace std;
class A
{
private: int X, Y;
public : A ( int myx, int myy) { X = myx; Y = myy ;}
void show ( ) { cout << "X =" << X << " Y = " << Y << endl;}
};
class B : public A
{
private : int H, W;
public: B ( int myx, int myy, int myh, int myw) : A ( myx, myy) [ H = myh ; W = myw;}
void show ( ) { cout << "H = " << H << " ; W = " << W << endl; }
};
void main( )
{
B d(1,2,3,4) ;
d. show ( ) ;
}
[填空题]有以下程序;
#include
using namespaCe std;
int main( )
{
int i=010,j=10;
cout<<(++i)<<","< return 0;
)
则该程序运行后的输出结果是【6】 。
[填空题]以下程序的功能是:将输入的正整数按逆序输出。例如:若输入135则输出531,请填空。
#include
main( )
int n,s;
printf("Enter a number:"); scanf("%d",&n);
printf("Output: ");
do
s=n%10; printf("%d",s); ______;
while(n!=0);
printf("/n");
[单项选择]有如下程序:
#include
#include
using namespace std;
class MyString{
public;
char str[80];
MyString(const char*s) {strcpy(str,s);}
MyString&operator+=(MyString a){
strcat(str,a.str);
return*this;
}
};
ostream&operator<<(ostream&s,const MyString&z){return s << z.str}
int main( ){
MyString x("abc"),y("cde");
cout<<(x+=y)<A. abc
B. cde
C. abcde
D. abccde
[简答题]有如下程序
#include
#include
using namespace std;
class MyClass{
public:
MyClass( ){cout<<’A”;}
MyClass(char c {cout<A. A.ABX
B.ABXB
C.AXB
D.AXBB
[单项选择]有如下程序
#include
using namespace std;
class Base{
protected:
Base( ){cout<<′A′;}
Base(char C){cout<A. B
B. BA
C. AB
D. BB
[填空题]以下程序的功能是:将输入的正整数按逆序输出。例如:若输入135,则输出531,请填空。
#include<stdio.h>
main( )
int n,s;
printf("Enter a number:");scanf("%d",&n);
printf("Output:");
do
s=n%10;printf("%d",s);______;
while(n!=0);
printf("/n");