下面的C题目为什么选择D?46.有以下程序#includestruct STU{ int num;float TotalScore;};void f(structSTU 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},{
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/20 00:22:47
下面的C题目为什么选择D?46.有以下程序#includestruct STU{ int num;float TotalScore;};void f(structSTU 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},{
下面的C题目为什么选择D?
46.有以下程序
#include
struct STU
{ int num;
float TotalScore;};
void f(structSTU 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.0f\n”,s[0].num,s[0].TotalScore);
}
程序运行后的输出结果是()
(A)20045 537
(B)20044 550
(C)20042 580
(D)20041 703
下面的C题目为什么选择D?46.有以下程序#includestruct STU{ int num;float TotalScore;};void f(structSTU 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},{
D啊,void f(structSTU p)传递的不是指针,所以函数里面对
structSTU p的操作实际上是一个结构体的备份而已,不会对传递进来的变量进行修改,如果想改变值的话void f(structSTU *p) ,调用的时候再传递一个指针或者地址进来
不知道哦。。