更多"有以下程序 #include<stdio.h> #include<"的相关试题:
[单项选择]有以下程序 #include<stdio.h> #include<string.h> Struct A {int a;char b[10];double c;}; struct A f(struct A t); main( ) {struct A a={1001,"ZhangDa",1098.0}; a=f(a);printf("%d,%s,%6.1f/n",a.a,a.b,a.c); } struct A f(Struct A t) {t.a=1002;strcpy(t.b,"WangPeng");t.c=1220.0;return t;} 程序运行后的输出结果是( )。
A. 1001,ZhangDa,1098.0
B. 1002,ZhangDa,1220.0
C. 1001,WangPeng,1098.0
D. 1002,WangPeng,1220.0
[填空题]以下程序运行后的输出结果是 【11】 。
#include <stdio.h>
struct NODE
int num;struct NODE * next;
main ( )
struet NODE s[3]= .’/0’,2,’/0’,3,’/O’,*p,*q,*r;
int sum = 0;
s[0].next=s+1; s[1].next=s+2;s[2].next=s;
p=s; q=p->next; r=q->next:
sum+=q->next->num; sum+=r->next->next->num;
prinff( "% d /n", sum);
[单项选择]下列程序的输出结果是( )。
#include<stdio.h>
main( )
struct st
int y,x,z;
;
union
long i;
int j;
char k;
un;
printf("%d,%d/n",sizeof(struct st),sizeof(un));
A. 6,2
B. 6,4
C. 8,4
D. 8,6
[填空题]以下程序运行后的输出结果是______。
struct NODE
int k;
struct NODE*link;
;
main( )
struct NODEm[5],*p=m,*q=m+4;
int i=0:
while(p!=q)
p->k=++i;p++;q->k=1++;q--;
q->k=i:
for(i=0;i<5;i++)printf("%d",m[i].k);
printf("/n");
[填空题]以下程序运行后的输出结果是______。
struct NODE
{int hum;struct NODE *next;
} ;
main( )
{structNODE s[3]={{1,’/0’},{2,’/0’},{3,’/0’}}, *p, *q, *r;
int sum=0;
s[0].next=s+1;s[1].next=s+2;s[2].next=s;
p=S;q=p->next;r=q->next;
sum+=q=>next->num;sum+=r->next->next->num;
printf("%d/n",sum);
}
[单项选择]有以下程序:
#include
usingnamespacestd;
classA{
public:
A(){cout<<"A";}
};
classB{public:B(){cout<<"B";}};
classC://publicA{
Bb;
public:
C(){cout<<"C";}
};
intmain(){Cobj;return0;}
执行后的输出结果是( )。
A. CBA
B. BAC
C. ACB
D. ABC
[单项选择]有以下程序
#include <iostream>
#include <string>
using namespace std;
class base
private:
char baseName[10];
public:
base ( )
strcpy(baseName,"Base");
virtual char *myName( )
return baseName;
char *className( )
return baseName;
;
class Derived : public base
private:
char derivedName[10];
public:
Derived( )
strcpy(derivedName,"Derived");
char *myName( )
return derivedName;
char *className( )
return derivedName;
;
void showPtr(base &p)
cout<<p.myName ( ) <<" "<<p.className ( );
int main ( )
base bb;
Derived dd;
showPtr(dd);
return 0;
运行后的输出结果为
A. Derived Base
B. Base Base
C. Derived Derived
D. Base Derived
[填空题]
以下程序运行后的输出结果是()。
#include
#include
#include
main( )
{ char *p;int i;
p=(char*)malloc(sizeof(char)*20);
strcpy(p,"welcome");
for(i=6;i>=0;i--) putchar(*(p+i));
printf("/n"); free(p);
}
[填空题]有以下程序:
#include<iostream>
#include<fstream>
using namespace std;
int main( )
fstream file;
file.open("abc.txt", ios :: in);
if ( !file )
cout<<"Can not open abc.txt"<<end1;
abort( );
char buf[ 80 ];
int i = 0;
while (!file.eof( ))
file.getline(buf,80);
i++;
cout<<"Lines :"<<i<<end1;
file.close( );
return 0;
程序实现的功能是 【15】 。
[单项选择]有以下程序:
#include <iostream>
#include <cstdlib>
using namespace std;
int main( )
int arraysize;
int *array;
cout<<"Please input the size of the array:";
cin>>arraySiZe;
array=new int[arraysize];
if(array==NULL)
cout<<"allocate Error/n";
exit(1);
for(int i=0;i<arraysize;i++)
array[i]=i*i;
int j;
cout<<"which element you want to check:";
cin>>j;
cout<<array[j]<<end1;
return 0;
执行程序输入:10<空格>5,则输出结果为( )。
A. allocate Error
B. 1
C. 0
D. 25
[单项选择]有以下程序:
#include<iostream>
#include<string>
using namespace std;
int main( )
char arr[2][4];
strcpy(arr[0],"you");
strcpy(arr[1],"me");
arr[0][3]=’&’;
cout<<arr[0]<<end1;
return 0;
执行后的输出结果是( )。
A. you&me
B. you
C. me
D. err