Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<conio.h>
- #define size 50
- struct student
- {
- char name[30];
- int num;
- float toan, li, hoa,tbm;
- };
- void nhap(struct student st[], int n)
- {
- int i;
- printf("THONG TIN SINH VIEN \n");
- for (i = 1;i <= n;i++)
- {
- printf("%d.ten va ma sinh vien: ", i);
- gets_s(st[i].name);
- while (getchar() != '\n');
- scanf_s("%d", &st[i].num);
- printf("toan li hoa \n");
- scanf_s("%f%f%f", &st[i].toan, &st[i].li, &st[i].hoa);
- st[i].tbm = (st[i].toan + st[i].li + st[i].hoa)/3;
- }
- }
- void xuat(struct student st[], int n)
- {
- int i;
- printf("\n\tthong tin SV lop K37-CNTT\n");
- printf("\n%-15s %-10s %-10s %-10s %-10s %-10s\n", "Ho Ten", "MSV", "Toan", "Li", "Hoa","DTB\n");
- for (i = 1;i <= n;i++)
- printf("\n%-15s %-10d %-10.2f %-10.2f %-10.2f %-10.2f", st[i].name, st[i].num, st[i].toan, st[i].li, st[i].hoa,st[i].tbm);
- }
- int main()
- {
- int i, n;
- struct student st[size];
- printf("so luong student la ");
- scanf_s("%d", &n);
- nhap(st, n);
- xuat(st, n);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment