题目
输入一个学生的学号,姓名,性别,用结构体存储,通过scanf读取后,然后再通过printf打印输出
输入
学号,姓名,性别,例如输入 101 xiongda m
输出
输出和输入的内容一致,如果输入的是101 xiongda m,那么输出也是101 xiongda m
案例
输入
101 xiongda m
输出
101 xiongda m
思路描述
这是一个简单的使用结构体的案例,主要考察定义结构体,以及使用结构体的属性。
代码
#include<stdio.h>
struct Student{
int number;
char name[40];
char sex;
};
int main()
{
struct Student stu;
scanf("%d %s %c",&stu.number,stu.name,&stu.sex);
printf("%d %s %c",stu.number,stu.name,stu.sex);
return 0;
}