《算法笔记》codeup_100000572_D

解答:

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

struct student {
	int id;
	char name[10];
	int score1;
	int score2;
	int score3;
};

void input(student* student_array) {
	for(int i=0; i<=4; i++) {
		scanf("%d %s %d %d %d", &(*(student_array+i)).id, (*(student_array+i)).name, &(*(student_array+i)).score1, &(*(student_array+i)).score2, &(*(student_array+i)).score3);
	}
}

void output(student* student_array) {
	for(int i=0; i<=4; i++) {
		printf("%d %s %d %d %d\n", (*(student_array+i)).id, (*(student_array+i)).name, (*(student_array+i)).score1, (*(student_array+i)).score2, (*(student_array+i)).score3);
	}
}

int main() {
	student* student_array = (student*)malloc(sizeof(student)*5);
	
	input(student_array);
	output(student_array);
	
	return 0;
}
发布了36 篇原创文章 · 获赞 3 · 访问量 1241

猜你喜欢

转载自blog.csdn.net/Zen_Ivan/article/details/105346367
今日推荐