Bob103

BEst 3!

May 16th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3. #include <fstream>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. ifstream in("Input.txt");
  9. ofstream out("Output.txt");
  10.  
  11. struct student
  12. {
  13. string fam, name, secondname;
  14. int mark[5];
  15. double key;
  16. void print();
  17. };
  18.  
  19. void student::print()
  20. {
  21. out << setw(12) << left << fam << setw(10) << name << setw(15) << secondname;
  22. for (int i = 0; i < 5; i++)
  23. out << setw(3) << mark[i];
  24. out << setw(5) << key << endl;
  25. }
  26.  
  27. void sort(int *a, int n)
  28. {
  29. int temp;
  30. int lowindex, lowkey, i, j;
  31. for (i = 0; i < n - 1; i++)
  32. {
  33. lowindex = i; lowkey = a[j];
  34. for (j = i + 1; j < n;j++)
  35. if (a[j] < lowkey)
  36. {
  37. lowkey = a[j];
  38. lowindex = j;
  39. }
  40. temp = a[i];
  41. a[i] - a[lowindex];
  42. a[lowindex] = temp;
  43. }
  44. }
  45. int main()
  46. {
  47. int n = 0, m, i;
  48. student stud[25];
  49. if (!in)
  50. cout << "Error,file Input.txt doesn't open";
  51. else
  52. {
  53. in >> m;
  54. while (in.peek() != EOF)
  55. {
  56. in >> stud[n].fam;
  57. in >> stud[n].name;
  58. in >> stud[n].secondname;
  59. for (i = 0; i < 5; i++)
  60. {
  61. in >> stud[n].mark[i];
  62.  
  63. }
  64. n++;
  65. }
  66. sort(stud, n);
  67. out << m << end;
  68. for (i = 0; i < n; i++)
  69. stud[i].print();
  70. }
  71. in.close();
  72. out.close();
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment