更多"下列程序的输出结果是 【8】 。
#include <iostre"的相关试题:
[单项选择]如下程序的输出结果是 #include<iostream> #include<iomanip> using namespace std; class CSum{ int x,y; public: CSum(int x0,int y0):X(x0),y(y0){ } friend ostream& operator<<(ostream& os,const CSum& xA) { os<<setw(5)<<xa.x+xa.y: return os; } }; int main( ){ CSum y(3,5); cout<<setfill(’*’)<<8; cout<<y; return 0; }
A. 88
B. ****88
C. ****8****8
D. 8****8
[填空题]以下程序的输出结果是 [9] 。
include<iostream.h>
include <string.h>
void main 0
char s[50];
strcpy(&s[O], "No" );
strcpy(&s[1], "123" );
strcpy (&s[2], "23456" );
cout<<s;
[单项选择]下面程序的输出结果是( )。
#include<iostream>
#include<math.h>
using namespace std;
class point
private:
double x;
double y;
public:
point(double a,double b)
x=a;
y=b;
friend double distances(point a,point b);
;
double distances(point a,point b)
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
int main( )
point p1(1,2);
point p2(5,2);
cout<<distances(p1,p2)<<end1;
return 0;
A. 2
B. 4
C. 8
D. 16
[填空题]下列程序输出结果是 【13】 。
include <iostream>
using namespace std;
template <typename T>
T fun(T a, T b) {return (a<=b)a:b;}
int main( )
{
cout<<fun(3,6)<<’,’<<fim(3.14F, 6.28F)<<end 1;
return 0;
}
[单项选择]如下程序的输出结果是
#include<iostream>
using namespace std;
class A
public:
A( )cout<<"A";
;
class Bpublic:B( )cout<<"B";;
class C://public A
B b;
public:
C( )cout<<"C";
;
int main( )C obj;return 0;
A. CBA
B. BAC
C. ACB
D. ABC
[单项选择]下列程序的输出结果是
#include"iostream"
using namespace std;
int Max(int a,int b)
if(a>b)
return a;
else
return b;
void main( )
int m,n;
m=10,n=5;
int max = Max(m,n);
cout<<max<<endl;
A. 10
B. 程序有误
C. 1
D. 0
[单项选择]下列程序的输出结果是
#include <iostream>
using namespace std;
int main ( )
char a[] = "Hello,World":
char*ptr = a;
while (*ptr)
if(*ptr>= ’a’ &&*ptr <=’z’
cout<<char*ptr+’A’-’a’);
else cout<<*ptr;
ptr++;
return 0;
A. HELLO. WORLD
B. Hello, World
C. hELLO, wORLD
D. hello, world
[填空题]下列程序的输出结果是 【9】 。
#include<iostream>
#include<cstring>
using namespace std;
void fun(const char*s,char &c) c=s[strlen(s)/2];
int main( )
char str[]="ABCDE";
char ch=str[1];
fun(str, ch);
cout<<ch;
return 0;
[单项选择]下面程序的输出结果是
#include<iostream.h>
#include<string.h>
voidmain( )
charp1[10],p2[10];
strcpy(p1,"abc");
strcpy(p2,"ABC");
charstr[50]="xyz";
strcpy(str+2,strcat(p1,p2));
cout<<str;
A. xyzabcABC
B. zabcABC
C. xyabcABC
D. yzabcABC
[单项选择]下面的程序输出结果是( )。
#include<iostream>
using namespace std;
void add( )
static int x;
x++;
cout<<x<<’’;
int main( )
for(int i=0;i<3;i++)
add( );
return 0;
A. 111
B. 123
C. 222
D. 333