tranght

Untitled

Feb 6th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. #include<conio.h>
  5. #define size 50
  6. struct student
  7. {
  8. char name[30];
  9. int num;
  10. float toan, li, hoa,tbm;
  11. };
  12. void nhap(struct student st[], int n)
  13. {
  14. int i;
  15. printf("THONG TIN SINH VIEN \n");
  16. for (i = 1;i <= n;i++)
  17. {
  18. printf("%d.ten va ma sinh vien: ", i);
  19. gets_s(st[i].name);
  20. while (getchar() != '\n');
  21. scanf_s("%d", &st[i].num);
  22. printf("toan li hoa \n");
  23. scanf_s("%f%f%f", &st[i].toan, &st[i].li, &st[i].hoa);
  24. st[i].tbm = (st[i].toan + st[i].li + st[i].hoa)/3;
  25. }
  26. }
  27. void xuat(struct student st[], int n)
  28. {
  29. int i;
  30. printf("\n\tthong tin SV lop K37-CNTT\n");
  31. printf("\n%-15s %-10s %-10s %-10s %-10s %-10s\n", "Ho Ten", "MSV", "Toan", "Li", "Hoa","DTB\n");
  32. for (i = 1;i <= n;i++)
  33. 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);
  34. }
  35. int main()
  36. {
  37. int i, n;
  38. struct student st[size];
  39. printf("so luong student la ");
  40. scanf_s("%d", &n);
  41. nhap(st, n);
  42. xuat(st, n);
  43. system("PAUSE");
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment