Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. // TUKursovaRabota1Zad1Kurs.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int** Opciq1(int NumberOfStudents){
  9. int** students=new int*[25];
  10. int FakNomer, specialnost, grupa;
  11. double SrUspeh;
  12. for (int rows = 0; rows < NumberOfStudents; rows++) {
  13. students[rows] = new int[4];
  14. for (int cols = 0; cols < 4; cols++) {
  15. switch (cols) {
  16. case 0: cout << "Enter Facultat number of " << rows + 1 << " student: "; cin >> FakNomer; students[rows][cols] = FakNomer; break;
  17. case 1: cout << "Enter Specialty of " << rows + 1 << " student: "; cin >> specialnost;
  18. while (true) {
  19.  
  20. if (specialnost == 52 || specialnost == 61) {
  21. students[rows][cols] = specialnost; break;
  22. }
  23. else {
  24. cout << "Wrong Input! Enter Specialty[52 or 61] of " << rows + 1 << " student: ";
  25. cin >> specialnost;
  26. }
  27. }
  28. break;
  29. case 2: cout << "Enter Group of " << rows +1<< " student: "; cin >> grupa;
  30. while (grupa < 1 || grupa>4) {
  31. cout << "Wrong input! Enter Group[1-4] of " << rows + 1 << " student: ";
  32. cin >> grupa;
  33. }
  34. students[rows][cols] = grupa; break;
  35. case 3: cout << "Enter Average Success of " << rows +1<< " student: "; cin >> SrUspeh;
  36. while (SrUspeh < 2 || SrUspeh>6) {
  37. cout << "Wrong input! Enter Average Success[2-6] of " << rows + 1 << " student: ";
  38. cin >> SrUspeh;
  39. }
  40. students[rows][cols] = SrUspeh; break;
  41. }
  42. }
  43. }
  44. /*
  45. for (int i = 0; i < NumberOfStudents; i++) {
  46. for (int cols = 0; cols < 4; cols++) {
  47. printf("\t%d", students[i][cols]);
  48. }
  49. printf("\n");
  50. }
  51. */
  52. return students;
  53.  
  54. }
  55.  
  56. void Opciq2(int** students,int NumberOfStudents) {
  57. int** studentsE = new int*[13];
  58. int rowE = 0;
  59. int rowAUIT=0;
  60. int** studentsAUIT = new int*[13];
  61. for (int row = 0; row < NumberOfStudents; row++) {
  62. if (students[row][1] = 52) {
  63. studentsE[rowE] = students[row];
  64. rowE++;
  65. }
  66. else if (students[row][1] = 61) {
  67. studentsAUIT[rowAUIT] = students[row];
  68. rowAUIT++;
  69. }
  70. }
  71. cout << "Students of specialty E(code52): "<<endl;
  72. for (int i = 0; i < NumberOfStudents; i++) {
  73. for (int cols = 0; cols < 4; cols++) {
  74. printf("\t%d", studentsE[i][cols]);
  75. }
  76. printf("\n");
  77. }
  78. cout << "Students of specialty AUIT(code61): " << endl;
  79. for (int i = 0; i < NumberOfStudents; i++) {
  80. for (int cols = 0; cols < 4; cols++) {
  81. printf("\t%d", studentsAUIT[i][cols]);
  82. }
  83. printf("\n");
  84. }
  85. }
  86. int main()
  87. {
  88.  
  89. int A = 1, B = 2, C = 3, G = 4;
  90. int switcher, N;
  91. int NumberStudents = 0;
  92.  
  93. int** studentsMain=0;
  94. do {
  95.  
  96. cout << "Choose action!" << endl;
  97. cout << "Press 1 to import data for N students into two-dimensional array." << endl;
  98. cout << "Press 2 to create two new arrays for students of Specialties E and AUIT and showing the result." << endl;
  99. cout << "Press 3 and choose a student by Facultat number,specialty and group." << endl;
  100. cout << "Press 4 to see all students with grade > 5.50 ." << endl;
  101. cout << "Press 5 to exit ." << endl;
  102. cin >> switcher;
  103. while (switcher < 1 || switcher >5)
  104. {
  105. cout << "Invalid option" << endl;
  106. cout << "Please pick an option between 1-5" << endl;
  107. cin >> switcher;
  108. }
  109. switch (switcher) {
  110. case 1: {
  111. cout << "Please input Number of students:";
  112. cin >> N;
  113. NumberStudents = N;
  114. int** students = Opciq1(N);
  115. students = studentsMain;
  116. break;
  117. }
  118. case 2: {
  119. Opciq2(studentsMain,NumberStudents);
  120. break;
  121. }
  122. case 3:
  123. break;
  124. case 4:
  125. break;
  126. }
  127. } while (switcher != 5);
  128.  
  129.  
  130. return 0;
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement