A: printf("%s",stu[2].name);
B: printf("%s",stu[1].name);
C: printf("%s",stu[2]);
D: printf("%s",stu[1]);
举一反三
- 根据下列的定义,能打印出字母P的语句是( ) struct stu char name[10]; int age; ; stmct stu s[10]="John",11, "Paul",12, "Mary",11, "adam",12 : A: printf("%c",s[3].name); B: printf("%c",s[3].name[1]); C: printf("%c",s[2].name[11]); D: printf("%c",s[1].name[0]);
- 根据下面的定义,能输出字符串'Mary'的语句是( )。struct worker{char name[18]; int age;};struct worker w[100]={"John",16,"Paul",17,"Mary",17 }; A: printf("%s",w[1].name); B: printf("%s",w[2].name); C: printf("%s",w[1]); D: printf("%s",w[2]);
- 以下结构体的定义语句中,正确的是______。? struct student {int num; char name[10];int age;}stu;|struct {int num; char name[10];int age;}student; struct student stu;|struct student {int num; char name[10]; int age;}; student stu;|struct student {int num; char name[10];int age;};stu;
- 有以下程序段,输出结果为()。 #include<stdio.h> struct student {int num; char name[20]; float score; }; main() {struct student stu[5]; printf("%d",sizeof(stu)); }
- 根据下面的定义,能输出字母'P'的语句是( )。struct worker{char name[18]; int age;};struct worker w[100]={"John",16,"Paul",17,"Mary",16 }; A: printf("%c",w[2].name[1]); B: printf("%c",w[1].name[0]); C: printf("%c",w[1].name); D: printf("%c",w[2].name[0]);
内容
- 0
根据程序,请判断输出结果:#include<stdio.h>struct stu{int num;char name[5];int age;char sex;};void fun(struct stu *p){printf("%s\n",(*p).name);}main(){struct stu stud[3]={{0001,"zhang",20,'f'},{0002,"li",18,'m'},{0003,"chen",19,'f'}};fun(stud+2);}
- 1
对结构体类型变量定义不正确的是( )。 A: B: define STUDENT struct studentSTUDENT{char name;int num;}std; C: struct student{char name;int num;}stu; D: E: define struct student{char name;int num;}STD;STD stu; F: struct{char name;int num;}student;struct student stu;
- 2
编写input()函数输入5个学生的数据记录。(用结构体设计,学生记录中包括学号、姓名、四门课程成绩).【1】、【2】分别填写的是( )。 #include#define N 5 struct student { char num[6]; char name[8]; int score[4]; } stu[N]; void input(struct student stu[]); void print(struct student stu[]); main() { input(stu); } void input(struct student stu[]) { int i,j; for(i=0;i A: stu[i].num B: stu[i+1].num C: stu[i].name D: stu[j].name
- 3
有如下定义struct person{ char name[9]; int age;}; struct person class[4]={ "Johu",17, "Paul",19, "Mary",18, "Adam",16};根据以上定义,能输出字母M的语句是( )。 A: printf("%c\n",class[3].name); B: printf("%c\n",class[3].name[1]); C: printf("%c\n",class[2].name[1]); D: printf("%c\n",class[2].name[0]);
- 4
分析下面的程序,下列说法中错误的是 ________ 。 #define NULL 0 #include "conio.h" struct stu { long num; char name[20]; int score; struct stu * next; }; int main() { struct stu *head,*p,*pa,*pb,*pc; pa=(struct stu *)malloc(sizeof(struct stu)); pb=(struct stu *)malloc(sizeof(struct stu)); pc=(struct stu *)malloc(sizeof(struct stu)); scanf("%ld%s%d",&pa->num,pa->name,&pa->score); scanf("%ld%s%d",&pb->num,pb->name,&pb->score); scanf("%ld%s%d",&pc->num,pc->name,&pc->score); head=pa; pa->next=pb; pb->next=pc; pc->next=NULL; p=head; while(p!=NULL) { printf("%ld,%s,%d\n",p->num,p->name,p->score); p=p->next; } }