Qian,m,85,90
Zhao,m,85,90
Qian,f,95,92
Zhao,f,95,92
第1题:
从键盘上输入XXYYZZXYZWXP和X,以下程序的输出结果是【 】。
include<iostream.h>
include<string.h>
void main(){
char*str,ch;
int count=0,pos;
cin>>str>>ch;
pos=strlen(str)-1;
while(pos>=0){
if((str[pos])=ch)count++;
pos--;
}
cout<<"count="<<count;
}
第2题:
执行下面的程序时,输入abc<CR>(其中CR代表回车),输出结果是( )。 #include<stdio.h> #include <string.h> main() { char ch; while((cn=getchar())!='n') { switch(ch-'a') { case 0: putchar(ch+1); case 1:putchar(ch+1);break; case 2:putchar(ch+2); caSe 3:putchar(ch+2);break; } } }
A.abc
B.bbc
C.abcd
D.bbcee
第3题:
下列程序的输出结果是______。
include<iostream.h>
include<string.h>
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;
}
第4题:
有以下程序 #include <stdio.h> #include <string.h> typedef struct { char name[9]; char sex; float score[2]; } STU; STU f(STU a) { STU b={"Zhao", 'm', 85.0, 90.0}; 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", T, 95.0, 92.0}, d; d=f(c); printf("%s,%c,%2.0f,%2.0f\n", d.name, &sex, &score[O], d.score[1]); } 程序的运行结果是
A.Qian, f,95,92
B.Qian,m,85,90
C.Zhao,m,85,90
D.Zhao,f,95,92
第5题:
当执行以下程序时,输入1234567890<回车>,则其中while循环体将执行【 】次。
include<stdio.h>
main()
{ char ch;
while((ch=getchar())=='0')prinft("");
}
第6题:
以下程序的运行结果是
#include "stdio.h"
main()
{struct date
{int year,month,day;}today;
printf("%d\n",sizeof(struct date));
}
A.6
B.8
C.10
D.12
第7题:
有以下程序 include<stdio.h> typedef struct { int num;double s; }REC; void funl(REC *x) { x->num=23;x->s=88.5; } void main() { REC a={16,90.0}; fun1(&A); printf("%d\n",a.num); } 程序运行后的输出结果是( )。
第8题:
有下列程序: #include <stdio.h> #include "string.h" typedef struct{char name[9]; char sex;float score[2];}STU; void f(STU A) { STU b={"Zhao",'m',85.0,90.0}; int i; strcpy(a.name,b.name); a.sex=b.sex; for(i=0;i<2;i++) a.score[i]=b.score[i]; } main() { STU c={"Qian",'f',95.0,92.0}; f(C) ; printf("%s,%c,%2.0f,%2.0f\n",c.name,c.sex,c.score[0],c.score[1]); } 程序的运行结果是( )。
A.Qian,f,95,92
B.Qian,m,85,90
C.Zhao,f,95,92
D.Zhao,m, 85,90
第9题:
有以下程序 #include <stdio.h> struct tt { int x; struct tt *y; } *p; struct tt a[4]= {20,a+ 1,15,a+2,30,a+3,17,a}; main() { int i; p=a; for(i=1; i<-2; i++) { printf("%d,", p->x ); p=p->y; }
A.20,30,
B.30,17
C.15,30,
D.20,15,
第10题:
下列程序的运行结果为【 】。
include<stdio.h>
include<string.h>
{ 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.lf\n",a.a,a.b,a.C);
}
void f(struct A*t)
{ strcpy(t->b, "ChangRong");}