26 lines
669 B
C
26 lines
669 B
C
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
typedef struct stu_s
|
||
|
{
|
||
|
unsigned short sid;
|
||
|
char name[32];
|
||
|
unsigned short hight;
|
||
|
float weight;
|
||
|
} STU_INFO;
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
STU_INFO stu;
|
||
|
for (int i = 0; i < 3; i++)
|
||
|
{
|
||
|
// 结构体清空数据
|
||
|
memset(&stu, 0, sizeof(STU_INFO)); // 清空结构体
|
||
|
printf("请输入学号 姓名 身高 体重:");
|
||
|
// %h 是短整型,%u 是无符号整型
|
||
|
scanf("%hu %s %hu %f", &stu.sid, stu.name, &stu.hight, &stu.weight);
|
||
|
printf("第%d位-->学号:%hu 姓名:%s 身高:%hu 体重:%.2f\n", i + 1, stu.sid, stu.name, stu.hight, stu.weight);
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|