定义student结构体,内容包括学号、
定义student结构体,内容包括学号、姓名、年龄,用student定义两位学生student1,student2,并对两位同学的信息进行初始化,输出两位学生的相关信息。...
定义student结构体,内容包括学号、姓名、年龄,用student定义两位学生student1,student2,并对两位同学的信息进行初始化,输出两位学生的相关信息。
展开
1个回答
展开全部
我写好了,先把源程序放在这里吧
#include<stdio.h>
#include<stdlib.h>
struct student
{
int number;
char name[10];
int age;
};
struct student student1;
struct student student2;
int main()
{
printf("\nplease input first student number:\n");
scanf("%d",&student1.number);
printf("please input first student name:\n");
scanf("%s",student1.name);
printf("please input first student age:\n");
scanf("%d",&student1.age);
printf("\nplease input second student number:\n");
scanf("%d",&student2.number);
printf("please input second student name:\n");
scanf("%s",student2.name);
printf("please input second student age:\n");
scanf("%d",&student2.age);
printf("\nfirst student number is:%d\n",student1.number);
printf("first student name is:%s\n",student1.name);
printf("first student age is:%d\n",student1.age);
printf("\nsecond student number is:%d\n",student2.number);
printf("second student name is:%s\n",student2.name);
printf("second student age is:%d\n",student2.age);
return 0;
}
我用的是VC++ 6.0,运行结果是这样的,最后输出两位同学的学号、姓名、年龄。
如果有什么不明白的还可以问我
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |