更多"有以下程序: #include <stdio.h> #includ"的相关试题:
[单项选择]有以下程序:
#include <stdio.h>
#include <string.h>
void f(char p[][10], int n) /*字符串从小到大排序*/
char t[10]; int i, j;
for (i=0; i<n-1; i++)
for(j=i+1; j<n; j++)
if (strcmp(p[i], p[j]) >0)
strcpy(t, p[i]);
strcpy(p[i], p[j]);
strcpy(p[j], t);
main( )
char p[5][10]="123", "aabdfg", "abbd", "dcdbe", "cd";
f(p, 5);
printf("% d/n ", strlen(p[0]) );
A. 2
B. 4
C. 6
D. 3
[填空题]
以下程序运行时输出到屏冪的结果中第一行是(),第二行是()。
#include
#include
Void compute(char*s)
{int t,r,
Char op;
For(r=0;isdigit(*s);s++) /*isdigit(*s)判断S指向的字符是否为数字字符*/
R=r*10+*s-‘0’;
While(*s)
{op=*s++;
For(t=0;isdigit(*s);s++)
T=t*10+*s-‘0’;
Switch(op)
{case’+’:r=r+t;break;
Case’-’:r=r-t;break;
Case’*’:r=r*t;break;
Case’/’:if(t)r=r/t;
else{puts(devide enor);return;}
}
}
Printf(%d/n,r);
}
Void main( )
{
compute(12+6-19+2);
Compute(12/6*19/2);
}
[单项选择]有以下程序
#include
#include
typedef struct {char name[9]; char sex; int score[2]; } STU;
STU f(STU a)
{ STU b={"Zhao",’m’,85,90};
int i;
strcpy(a.name,b.name);
a.sex=b.sex;
for(i=0;i<2;i++) a.score[i]=b. score[i];
return a;
}
main( )
{ STU c={"Qian",’f’,95,92}, d;
d=f(c);
printf("%s,%c,%d,%d,",d.name, d.sex, d.score[0], d.score[1]);
printf("%s,%c,%d,%d/n",c.name, c.sex, c.score[0], c.score[1]);
}
程序运行后的输出结果是_______。
A. Zhao,m,85,90,Qian,f,95,92
B. Zhao,m,85,90, Zhao,m,85,90
C. Qian,f,95,92, Qian,f,95,92
D. Qian,f,95,92, Zhao,m,85,90
[填空题]以下程序的输出结果是( )。
#include
#include
#include
mian( )
{ char *p, *q, *r;
p=q=r=(char *)malloc(sizeof(char)*20);
strcpy(p,”attaboy,welcome!”);
printf(“%c%c%c/n”,p[11], q[3], r[4]);
free(p);
}
[填空题]以下程序运行后的输出结果是【 】。
#include<iostream.h>
void fun(int x,int y)
{ x=x+y;y=x-y;x=x-y;
cout<< x << "," <<y << " ,";=
void main( )
{ int x=2,y=3;fun(x,y);
cout<< x << "," << y << endl;=
[单项选择]
有以下程序
#include
#include
struct A
{ int a; char b[10]; double c;};
void f(struct A t);
main( )
{ struct A a={1001,"ZhangDa",1098.0};
f(a); printf("%d,%s,%6.1f/n",a.a,a.b,a.c);
}
void f(struct A t)
{ t.a=1002; strcpy(t.b,"ChangRong");t.c=1202.0;}
程序运行后的输出结果是()
A. 1001,zhangDa,1098.0
B. 1002,changRong,1202.0
C. 1001,ehangRong,1098.O
D. 1002,ZhangDa,1202.0
[单项选择]有以下程序:
#include <stdio.h>
void f(int v, int w)
int t;
t=v; v=w; w=t;
main( )
int x=1,y=3,z=2;
if(x>y) f(x,y);
else if(y>z) f(y,z);
else f(x,z);
printf("%d,%d,%d/n",x,y,z);
执行后的输出结果( )。
A. 1,2,3
B. 3,1,2
C. 1,3,2
D. 2,3,1
[填空题]
有以下程序
#include
#include
void fun(char *str)
{ char temp;int n,i;
n=strlen(str);
temp=str[n-1];
for(i=n-1;i>0;i--) str[i]=str[i-1];
str[0]=temp;
}
main( )
{ char s[50];
scanf("%s",s); fun(s); printf("%s/n",s);}
程序运行后输入:abcdef<回车>,则输出结果是 () 。
[单项选择]有以下程序 #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<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
[单项选择]以下程序的输出结果是( )。
#include<iostream.h>
int x=3;
void main( )
void fun( );
int i;
for(i= 1 ;i<x;i++)
fun( );
void fun( )
static int x=1 ;
x*=x+ 1;
cout<<x<<" ";
A. 3, 3
B. 2, 2 C) 2, 6 D) 2, 5
[单项选择]有以下程序
#include
#include
void fun(char *w, int m)
{ char s, *p1, *p2;
p1=w; p2=w+m-1;
while(p1A. 654321
B. 116611
C. 161616
D. 123456