stu
有以下程序
#include
#include
typedef struct { char name[9]; char sex; float score[2]; } STU;
void f(STU A)
{
STU b={"Zhao", 'm', 85.0, 90.0};
int i;
strcpy(a.name, b.name);
a.sex = b.sex;
for (i=0; i<2; i++)
a.score[i] = b.score[i];
}
main()
{
STU c={"Qian", 'f', 95.0, 92.0};
f(c);
printf("%s,%c,%2.0f,%2.0f\n", c.name, c.sex, c.score[0], c.score[1]);
}
程序的运行结果是
有以下程序
#include
#include
typedef struct { char name[9]; char sex; float score[2]; } STU;
STU f(STU A)
{ STU b={"Zhao", 'm', 85.0, 90.0}; int i;
strcpy(a.name, b.name);
a.sex = b.sex;
for (i=0; i<2; i++) a.score[i] = b.score[i];
return a;
}
main()
{ STU c={"Qian", 'f', 95.0, 92.0}, d;
d=f(c);
printf("%s,%c,%2.0f,%2.0f\n",d.name,d.sex,d.score[0],d.score[1]);
}
程序的运行结果是
若有以下程序
#include
typedef struct stu {
char name[10], gender;
int score;
} STU;
void f(STU a, STUB)
{ b = a;
printf( "%s,%c,%d,", b.name, b.gender, b.score );
}
main()
{ STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350};
f(a,b);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}
则程序的输出结果是
有以下程序
#include
typedef struct stu {
char name[10];
char gender;
int score;
} STU;
void f(STU *a, STU *b)
{ b = a;
printf("%s,%c,%d,", b->name, b->gender, b->score);
}
main()
{ STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350};
f(&a,&b);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}
程序的运行结果是
有以下程序
#include
typedef struct stu {
char name[10];
char gender;
int score;
} STU;
void f(STU *a, STU *b)
{ *b = *a;
printf("%s,%c,%d,", b->name, b->gender, b->score);
}
main()
{ STU a={"Zhao", 'm', 290}, b={"Qian", 'f', 350};
f(&a,&b);
printf("%s,%c,%d\n", b.name, b.gender, b.score);
}
程序的运行结果是