scanf(%s,zhangsan->name);
scanf(%s,zhangsan.name);
scanf(%s,ptr->name);
scanf(%s,(*ptr).name);
第1题:
有以下程序 #include <stdio.h> #include <string.h> typedef strtlct{ char name[9]; char sex;floatscore[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
A.Qian,f,95,92
B.Qian,m,85,90
C.Zhao,f,95,92
D.Zhao,m,85,90
第2题:
设有如下定义 struct ss { char name[10]; int age; char sex; } std[3],* p=std; 下面各输入语句中错误的是
A.scanf("%d",&(*p).age);
B.scanf("%s",&std.name);
C.scanf("%c",&std[0].sex);
D.scanf("%c",&(p->sex));
第3题:
有以下程序
#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",'f',95.0,92.0},d;
d=f(c); printf("%s,%c,%2.0f,%2.0f\n",d.name,d.sex,d.score[0],d.score[1]);
}
程序的运行结果是
A)Qian,f,95,92
B)Qian,m,85,90
C)Zhao,m,85,90
D)Zhao,f,95,92
第4题:
有以下程序: #include <string.h> struct STU (char name[10]; int num; }; void f(char *name, int num) {struct STU s[2]={{"SunDan",20044}.{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() {struct STU s[2]={{"YangSall",20041},{"LiSiGao",20042}},*p;p=&s[1]; f(p->name,p->num); printf("%s%d\n",p->name,p->num); } 程序运行后的输出结果是 ______。
A.SunDan 20042
B.SunDan 20044
C.LiSiGuo 20042
D.YangSan 20041
第5题:
有以下程序 #include <string.h> struct STU { char name[10]; int num; }; void f(char *name, int num) { struct STU s[2]={{"SunDan",20044},{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() { struct STU s[2]={{"YangSan",20041},{"LiSiGuo",20042}},*p; p=&s[1]; f(p->name,p->num); printf("%s %d\n",p->name,p->num); } 程序运行后的输出结果是
A.SunDan 20042
B.SunDan 20044
C.LiSiGuo 20042
D.YangSan 20041
第6题:
有下列程序: #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
第7题:
有以下程序:
include <iostream>
include <string>
using nameSpace std;
class person
{
int age;
Char * name;
public:
person ( int i, Char * str )
{
int j;
j = strlen( str ) + 1;
name = new char[ j ];
strcpy( name, str );
age = i;
}
~person()
{
delete name;
cout<<"D";
}
void display()
{
cout<<name<<":"<<age;
}
};
int main()
{
person demo( 30,"Smith" );
demo.display();
return 0;
}
则该程序的输出结果为:【 】。
第8题:
有以下程序
#include <stdio.h>
main()
{
struct STU { char name[9]; char sex; double score[2];};
struct STU a={"Zhao",'m',85.0,90.0},b={"Qian",'f',95.0,92.0};
b=a;
printf("%s,%c,%2.0f,%2.0f\n", b.name, b.sex, b.score[0], b.score[1]);
}
程序的运行结果是
A)Qian,f,95,92
B)Qian,m,85,90
C) Zhao,f,95,92
D)Zhao,m,85,90
第9题:
下面程序和运行运行结果是【 】。
typedef union student
{ char name [10];
long sno;
char sex;
float score [4];
} STU;
main ( )
{ STU a[5];
prinff( "% d\n", sizeof(a) );
}
第10题:
有以下程序 #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