结构体数组的输入与输出

输入学生的姓名、性别、年龄

使用结构体输出对应数据

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct student
{
	char name[10];
	char sex;
	long age;
	float score[3];
};

int main(){

	struct student stu;
	int i;
	scanf("%s %c %ld",stu.name,&stu.sex,&stu.age);
	for(i=0;i<3;i++)
	{
		scanf("%f",&stu.score[i]);	
	}

	printf("Name	Sex    Age    Score1    Score2    Score3\n");
	printf("%-8s %-2c %8ld",stu.name,stu.sex,stu.age);
	for(i=0;i<3;i++)
	{
		printf("%8.2f",stu.score[i]);		
	}	

return 0;
	
}

全部评论

相关推荐

嵐jlu:我是山川🐔里🐔🧱的,阿里系简历全过; 你这简历一看就还是半成品啊,没有荣誉经历奖项什么的吗?
投递阿里巴巴集团等公司10个岗位
点赞 评论 收藏
分享
半解316:内容充实,细节需要修改一下。 1,整体压缩为一页。所有内容顶格。 2,项目描述删除,直接写个人工作量 修改完之后还需要建议,可以私聊
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务