• 2022-06-09
    根据程序,请判断输出结果:#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);}
  • chen

    举一反三

    内容

    • 0

      以下程序执行后的输出结果是#include struct STU{ char name[10]; int num;};void Fun1(struct STU c){ struct STU b={LiGuo,2042}; c=b;};int main(){ struct STU a={YangHan,2041},b={WangYi,2043}; Fun1(a); printf(%d %d ,a.num,b.num); return 0;}

    • 1

      分析下面的程序,下列说法中错误的是 ________ 。 #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; } }

    • 2

      对以下定义,能输出字符串"Mary"的语句是( )。struct student { char name&#91;20&#93;; int age; }; struct student stu&#91;100&#93;={"John",16,"Paul",17,"Mary",18 }; A: printf("%s",stu[2].name); B: printf("%s",stu[1].name); C: printf("%s",stu[2]); D: printf("%s",stu[1]);

    • 3

      中国大学MOOC: 写出下面程序执行后的运行结果。#include <stdio.h>struct STU {char name[10]; int num;};void f1(struct STU c){struct STU b={"LiSiGuo",2042};c=b;}void f2(struct STU *c){struct STU b={"SunDan",2044};*c=b;}int main( ){struct STU a={"YangSan",2041},b={"WangYin",2043};f1(a); f2(&b) ;printf("%d %d",a.num,b.num); return 0;}

    • 4

      编写input()函数输入5个学生的数据记录。(用结构体设计,学生记录中包括学号、姓名、四门课程成绩).【1】、【2】分别填写的是( )。 #include#define N 5 struct student { char num&#91;6&#93;; char name&#91;8&#93;; int score&#91;4&#93;; } stu&#91;N&#93;; void input(struct student stu&#91;&#93;); void print(struct student stu&#91;&#93;); main() { input(stu); } void input(struct student stu&#91;&#93;) { int i,j; for(i=0;i A: stu[i].num B: stu[i+1].num C: stu[i].name D: stu[j].name