更多"下面程序运行时输出结果为 【8】 。
#include<iostre"的相关试题:
[填空题]下面程序运行时输出结果为 【8】 。
#include<iostream.h>
#include<malloc.h>
class Rect
public:
Rect(int1,int w)(length=1;width=w;)
void Print( )cout<<"Area:"<<length *width<<endl;)
void *operator new(size-t size)return malloc(size);
void operator delete(void *p)free(p)
private:
int length,width;
;
void main( )
Rect*p;
p=new Rect(5,4);
p->Print( );
delete p;
[填空题]下面程序运行时输出结果为______。
#include<iostream.h>
#include
class Rect
{
public:
Rect(int l, int w){length=l; width=w;)
void Print( ){cout<<"Area:"<<length*width<<end1;}
void operator delete(void*p){free(p);}
private:
int length, width;
};
void main( )
{
Rect *p;
p=new Rect(5, 4);
p->Print( );
delete p;
}
[填空题]下面程序运行时输出结果为______。
#include <iostream.h>
#include <malloc.h>
class Rect
public:
Rect(int l,int w) length=l;width=w;)
void Print( ) cout<<"Area:"<<length*width<<endl;
void *operator new(size-t size) return malloc(size);
void operator delete(void *p)free(p
private:
int length,width;
;
void main( )
Rect *p;
p=new Rect(5,4);
p->Print( );
deletep;
[填空题]下面程序运行时输出结果为______。
#include<iostream.h>
#include
class Rect
public:
Rect(int l, int w)length=l; width=w;)
void Print( )cout<<"Area:"<<length*width<<end1;
void operator delete(void*p)free(p);
private:
int length, width;
;
void main( )
Rect *p;
p=new Rect(5, 4);
p->Print( );
delete p;
[填空题]若下面程序运行时输出结果为
1,A,10.1
2,B,3.5
#include <iostream>
using namespace std;
int main( )
{
void test(int, char, doubie 【8】 );
test(1, ’A’, 10.1 );
test(2, ’B’);
return 0;
}
void test(int a, char b, double c)
{
cout<<a<<’,’<<b<<’,’<<c<<endl;
}
[单项选择]如下程序运行时的输出结果是
#include<iostream>
using namespace std;
class ONE
int c;
public:
ONE( ):c(0)eout<<1;
ONE(int n):C(n)cout<<2;
;
class TW0
ONE onel;
ONE one2;
public:
TWO(int m):one2(m)eout<<3;
;
int main( )
TWO t(4);
return 0;
A. 3
B. 23
C. 123
D. 213
[单项选择]如下程序运行时的输出结果是 #include<iostream> using namespace std; class ONE{ int c; public: ONE( ):c(0){eout<<1;} ONE(int n):C(n){cout<<2;} }; class TW0{ ONE onel; ONE one2; public: TWO(int m):one2(m){eout<<3;} }; int main( ){ TWO t(4); return 0; }
A. 3
B. 23
C. 123
D. 213
[填空题]
以下程序运行时输出结果是()。
#include
#include
int count(char s[])
{ int i=0;
if(s[i]==’/0’) return 0;
while(isalpha(s[i]))i++;
while(!isalpha(s[i])&&s[i]!=’/O’)i++;
return 1+count(&s[i]);
}
void main( )
{char line[]="one world,one dream.";
printf("%d",count(line));
}
[填空题]在下面的程序运行时,如果从键盘上输入1298并回车,则输出结果为 [7] 。
# include <iostream. h>
void main( )
int n1, n2;
cin>>n2;
while (n2!=0)
n1=n2%10;
n2=n1/10;
cout<<rd<< ","
[填空题]以下程序运行时输出到屏幕的结果是【16】 。
#include
#include
void main( )
{ int i=0,n=0;char s[80],*p;
strcpy(s,"It is a book.");
for(p=s;p!=’/0’;p++)
if(*p==’ ’)
i=0;
else
if(i==0)
{n++;i=1; }
printf("%d/n",n);
}
[填空题]以下程序运行时输出到屏幕的结果是【10】。
#include
int fun(int *x,int n)
{if(n==0) return x[0];
else return x[0]+fun(x+1,n-1);
}
void main( )
{int a[ ]={1,2,3,4,5,6,7};
printf("%d/n",fun(a,2));
[填空题]以下程序运行时输出到屏幕的结果是【6】 。
#include
void main( )
{FILE *fp;
int k,n,a[6]={1,2,3,4,5,6};
fp=fopen("d2.dat","w"); ’
fprintf(fp,"%d%d%d/n",a[0],a[1],a[2]);
fprintf(fp,"%d%d%d/n",a[3],a[4],a[5]);
fclose(fp);
fp=fopen("d2.dat","r");
fscanf(fp,"%d%d",&k,&n);
printf("%d,%d/n",k,n);
fclose(fp);
}
[填空题]以下程序运行时输出到屏幕的结果是 【7】。
#include
void main( )
{int i=1,m=0;
switch(i)
{ case 1:
case 2: m++;
case 3: m++;
}
printf("%d",m);
}
[填空题]下列程序运行时的输出结果是___【8】___。
#include<iostream>
using namespace std;
int Xfun(int*a, int n);
int main( )
int b[6]={-2, 6, 8, -3, 5, 4);
cout<<Xfun(b, 6)<<end1;
return 0;
}
int Xfun(int*a, int n){
int x=0;
for(int*p=a; p<a+n; p++)if(*p>0)x+=*p;
return X;
}
[填空题]下列程序运行时的输出结果是__【9】____。
#include<iostream>
using namespace std;
void Xfun(int&, int&);
int main( ){
int a=3, b=4;
Xfun(a, B) ;
cout<<a*a+b<<end1;
return 0;
}
void Xfun(int& x, int& y){
int z=x;
x=y; y=z;
}