Advertisement
Guest User

Untitled

a guest
May 28th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. // ConsoleApplication40.cpp : Defines the entry point for the console application.
  2. //
  3. #include <string>
  4. #include <iostream>
  5. #include "stdafx.h"
  6. #include <conio.h>
  7. #include <stdlib.h>
  8. using namespace std;
  9.  
  10. struct student
  11. {
  12. char name[20];
  13. int group;
  14. int mark[4];
  15. };
  16.  
  17.  
  18. int _tmain(int argc, _TCHAR* argv[])
  19. {
  20. int n = 0;
  21. cout << "Enter number of students" <<endl ;
  22. cin >> n;
  23. student *obj1;
  24. obj1 = new student[n];
  25.  
  26. for (int i = 0; i < n; i++)
  27. {
  28. system("CLS");
  29. cin.ignore();
  30. cout << "Enter info about " << i+1 << " student" << endl;
  31. cout << "\n";
  32.  
  33. cout << "Name: "; gets(obj1[i].name);
  34. puts("group-");
  35. scanf("%ld", &obj1[i].group);
  36. puts("1exm-");
  37. scanf("%ld", &obj1[i].mark[0]);
  38. puts("2exm-");
  39. scanf("%ld", &obj1[i].mark[1]);
  40. puts("3exm-");
  41. scanf("%ld", &obj1[i].mark[2]);
  42. puts("4exm-");
  43. scanf("%ld", &obj1[i].mark[3]);
  44.  
  45.  
  46.  
  47. system("CLS");
  48. }
  49.  
  50. double avr[] = {0,0,0,0};
  51. for (int p = 0; p < n; p++)
  52. {
  53. avr[0] += obj1[p].mark[0];
  54. avr[1] += obj1[p].mark[1];
  55. avr[2] += obj1[p].mark[2];
  56. avr[3] += obj1[p].mark[3];
  57.  
  58. }
  59.  
  60. avr[0] = avr[0] / n;
  61. avr[1] = avr[1] / n;
  62. avr[2] = avr[2] / n;
  63. avr[3] = avr[3] / n;
  64.  
  65. double max;
  66. max = avr[0];
  67. for (int o = 0; o < 4; o++)
  68. {
  69. if (max < avr[o])
  70. {
  71. max = avr[o];
  72. }
  73. }
  74. for (int u = 0; u < 4; u++)
  75. {
  76. if (max == avr[u])
  77. {
  78. cout << "Exam " << u+1 << " most successful with average score: " << max << endl;
  79. }
  80. }
  81.  
  82.  
  83. delete []obj1;
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement