有以下程序: #include<stdio.h> #include<string.h> structA { int a;char b[10];double c;); structA f(structA t);

admin2019-01-11  19

问题 有以下程序:
#include<stdio.h>
    #include<string.h>
    structA
    {  int a;char b[10];double c;);
       structA f(structA t);
       main()
       {  structAa={1001,"ZhangDa",1098.0);
          a=f(a);printf("%d,%s,%6.1 f\n",a.a,a.b,a.c);
       }
       structAf(structA t)
    {   t.a=1002;strcpy(t.b,"ChangRong");t.c=1202.0;return t;}
    程序运行后的输出结果是(    )。【09年9月】

选项 A、1001,ZhangDa,1098.0
B、1002,ZhangDa,1202.0
C、1001,ChangRong,1098.0
D、1002,ChangRong,1202.0

答案D

解析 在主函数中定义结构体A的变量a,并对其赋初值,再调用函数f(a),在函数f(a)中对结构体变量a的各个成员重新进行了赋值操作,并把其值返回在屏幕上输出。
转载请注明原文地址:https://kaotiyun.com/show/hixp777K
0

最新回复(0)