问题 单项选择题

有以下程序:
#include <stdio, h>
#include <string, h>
struet STU
int nam;
float TotalSeore;
;
void f( strnct 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. Of\n" ,s[0].num,s[0].TotalSeore);
程序运行后的输出结果是( )。

A.20045 537

B.20044 550

C.20042 580

D.20041 703

答案

参考答案:D

解析: 函数f中定义了结构体类型的变量P作为形参,在main函数中,将结构体变量 s[0]中的值传给了形参变量P,在函数f中,虽然改变了p中的内容,但其改变对main函数中 s[0]的值不产生影响,所以main函数中输出s[0]的数据仍然是main函数中初始化时的数据。

填空题
问答题