-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCPLB_L_A08_OPT1_EX1.c
61 lines (53 loc) · 1.41 KB
/
CPLB_L_A08_OPT1_EX1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct Student
{ int IDSV;
char name[30];
int age;
char grade[30];
float GPA;
};
typedef struct Student student;
student sv;
void InputStudentInfo(student *sv) {
//Nhập thông tin sinh viên:
printf("Nhap ID sinh vien hien tai: ");
fflush(stdin);
scanf("%d",&sv->IDSV);
printf("Nhap ten sinh vien tuong ung voi ID: ");
fflush(stdin);
fgets(sv->name,sizeof(sv->name),stdin);
printf("Nhap vao tuoi cua sinh vien: ");
fflush(stdin);
scanf("%d",&sv->age);
printf("Nhap vao grade cua sinh vien: ");
fflush(stdin);
fgets(sv->grade,sizeof(sv->grade),stdin);
printf("Nhap vao so GPA cua sinh vien: ");
fflush(stdin);
scanf("%f",&sv->GPA);
}
void OutputStudentInfomation(student sv) {
printf("\nName: %s",sv.name);
printf("ID: %d\n",sv.IDSV);
printf("Age: %d\n",sv.age);
printf("Grade: %s\n",sv.grade);
printf("GPA: %g",sv.GPA);
}
int main() {
int i;
int numberOfStudent;
printf("Hay nhap vao so luong sinh vien");
scanf("%d",&numberOfStudent);
student StudentList[numberOfStudent];
for (i = 0; i < numberOfStudent; i++)
{
InputStudentInfo(&StudentList[i]);
}
for (i = 0; i < numberOfStudent; i++)
{
OutputStudentInfomation(StudentList[i]);
}
return 0;
}