早教吧作业答案频道 -->其他-->
#include#includestructA{inta;charb[10];doublec;};voidf(structAt);#include#includestructA{inta;charb[10];doublec;};voidf(structAt);main(){structAa={1001,"ZhangDa",1098.0};f(a);pringt("%d,%s,%6.1f\n",a.a,a.b,a.c);}voi
题目详情
#include #include struct A {int a; char b[10];double c;}; void f(struct A t);
#include
#include
struct A
{int a; char b[10];double c;};
void f(struct A t);
main()
{struct A a={1001,"ZhangDa",1098.0};
f(a); pringt("%d,%s,%6.1f\n",a.a,a.b,a.c);
}
void f(struct A t)
{t.a=1002;strcpy(t.b,"ChangRong");t.c=1202.0;}
程序运行后的输出结果是
#include
#include
struct A
{int a; char b[10];double c;};
void f(struct A t);
main()
{struct A a={1001,"ZhangDa",1098.0};
f(a); pringt("%d,%s,%6.1f\n",a.a,a.b,a.c);
}
void f(struct A t)
{t.a=1002;strcpy(t.b,"ChangRong");t.c=1202.0;}
程序运行后的输出结果是
▼优质解答
答案和解析
f()函数执行的时候,a的值传给t,t被赋值,但是a没变.所以还是输出1001,ZhangDa,1098.0
可以用指针解决
#include “stdio.h”
#include “string.h”
struct A{
\x05int a;
char b[10];
\x05double c;
};
void f(struct A *t);
main(){
\x05struct A a={1001,"ZhangDa",1098.0};
\x05f(&a);
\x05printf("%d,%s,%6.1f\n",a.a,a.b,a.c);
}
void f(struct A *t){
\x05t->a=1002;
\x05strcpy(t->b,"ChangRong");
t->c=1202.0;
}
可以用指针解决
#include “stdio.h”
#include “string.h”
struct A{
\x05int a;
char b[10];
\x05double c;
};
void f(struct A *t);
main(){
\x05struct A a={1001,"ZhangDa",1098.0};
\x05f(&a);
\x05printf("%d,%s,%6.1f\n",a.a,a.b,a.c);
}
void f(struct A *t){
\x05t->a=1002;
\x05strcpy(t->b,"ChangRong");
t->c=1202.0;
}
看了 #include#inclu...的网友还看了以下:
从A、B、C、D四个选项中选出与所给单词的划线部分读音相同的选项。pronounce[]A.cou 2020-05-13 …
A.equalB.doubleC.subjectD.dealE.remarkablyF.suppo 2020-07-17 …
三角形、梯队、圆形的类封装AreaAndLength.javaclassTrangle{doubl 2020-07-17 …
c语言求解34.在C程序中,若未在函数定义时说明函数类型,则函数默认的类型为()。A.voidB. 2020-07-17 …
#include#includestructA{inta;charb[10];doublec;}; 2020-07-23 …
Hesaidinhisletterthathewould()somephotographsbutIc 2020-11-01 …
C++现在有三个函数。问题在下面。(1).doubleAdd(doublea)(2).doubleA 2020-11-23 …
\C语言规定,若未对函数返回类型加以说明,则函数的隐含类型为()选择一个答案A.voidB.doub 2020-12-02 …