有以下程序:    #include  <strino.h>    struct  STU    {int  num;    float  TotalScore;    };    void f(struct STU  p)    {struct STU 

admin2009-02-15  12

问题 有以下程序:    #include  <strino.h>    struct  STU    {int  num;    float  TotalScore;    };    void f(struct STU  p)    {struct STU  s[2]={{20044,550},{20045,537}};    p.num=s[1].num;p.TotalScore=s[1].TotalScore;    }    main()    {struct STU  s[2]={{20041,703},{20042,580}};    f(s[0]);    printf("%d%3.0t\n",s[0].num,s[0].TotalScore);    }    程序运行后的输出结果是 ______。

选项 A、20045  537
B、20044  550
C、20042  580
D、20041  703

答案D

解析 本题定义了结构体类型的变量P作为形参,并将结构体变量s[0]中的值传递给了形参变量p,在函数f中,又对p中的内容作了改变,但这种改变对工函数中s[0]的值并不产生影响,所以主函数中输出s[0]的数据依然是在主函数中初始化时的数据。
转载请注明原文地址:https://kaotiyun.com/show/AqXp777K
0

随机试题
最新回复(0)