Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TUKursovaRabota1Zad1Kurs.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int** Opciq1(int NumberOfStudents){
- int** students=new int*[25];
- int FakNomer, specialnost, grupa;
- double SrUspeh;
- for (int rows = 0; rows < NumberOfStudents; rows++) {
- students[rows] = new int[4];
- for (int cols = 0; cols < 4; cols++) {
- switch (cols) {
- case 0: cout << "Enter Facultat number of " << rows + 1 << " student: "; cin >> FakNomer; students[rows][cols] = FakNomer; break;
- case 1: cout << "Enter Specialty of " << rows + 1 << " student: "; cin >> specialnost;
- while (true) {
- if (specialnost == 52 || specialnost == 61) {
- students[rows][cols] = specialnost; break;
- }
- else {
- cout << "Wrong Input! Enter Specialty[52 or 61] of " << rows + 1 << " student: ";
- cin >> specialnost;
- }
- }
- break;
- case 2: cout << "Enter Group of " << rows +1<< " student: "; cin >> grupa;
- while (grupa < 1 || grupa>4) {
- cout << "Wrong input! Enter Group[1-4] of " << rows + 1 << " student: ";
- cin >> grupa;
- }
- students[rows][cols] = grupa; break;
- case 3: cout << "Enter Average Success of " << rows +1<< " student: "; cin >> SrUspeh;
- while (SrUspeh < 2 || SrUspeh>6) {
- cout << "Wrong input! Enter Average Success[2-6] of " << rows + 1 << " student: ";
- cin >> SrUspeh;
- }
- students[rows][cols] = SrUspeh; break;
- }
- }
- }
- /*
- for (int i = 0; i < NumberOfStudents; i++) {
- for (int cols = 0; cols < 4; cols++) {
- printf("\t%d", students[i][cols]);
- }
- printf("\n");
- }
- */
- return students;
- }
- void Opciq2(int** students,int NumberOfStudents) {
- int** studentsE = new int*[13];
- int rowE = 0;
- int rowAUIT=0;
- int** studentsAUIT = new int*[13];
- for (int row = 0; row < NumberOfStudents; row++) {
- if (students[row][1] = 52) {
- studentsE[rowE] = students[row];
- rowE++;
- }
- else if (students[row][1] = 61) {
- studentsAUIT[rowAUIT] = students[row];
- rowAUIT++;
- }
- }
- cout << "Students of specialty E(code52): "<<endl;
- for (int i = 0; i < NumberOfStudents; i++) {
- for (int cols = 0; cols < 4; cols++) {
- printf("\t%d", studentsE[i][cols]);
- }
- printf("\n");
- }
- cout << "Students of specialty AUIT(code61): " << endl;
- for (int i = 0; i < NumberOfStudents; i++) {
- for (int cols = 0; cols < 4; cols++) {
- printf("\t%d", studentsAUIT[i][cols]);
- }
- printf("\n");
- }
- }
- int main()
- {
- int A = 1, B = 2, C = 3, G = 4;
- int switcher, N;
- int NumberStudents = 0;
- int** studentsMain=0;
- do {
- cout << "Choose action!" << endl;
- cout << "Press 1 to import data for N students into two-dimensional array." << endl;
- cout << "Press 2 to create two new arrays for students of Specialties E and AUIT and showing the result." << endl;
- cout << "Press 3 and choose a student by Facultat number,specialty and group." << endl;
- cout << "Press 4 to see all students with grade > 5.50 ." << endl;
- cout << "Press 5 to exit ." << endl;
- cin >> switcher;
- while (switcher < 1 || switcher >5)
- {
- cout << "Invalid option" << endl;
- cout << "Please pick an option between 1-5" << endl;
- cin >> switcher;
- }
- switch (switcher) {
- case 1: {
- cout << "Please input Number of students:";
- cin >> N;
- NumberStudents = N;
- int** students = Opciq1(N);
- students = studentsMain;
- break;
- }
- case 2: {
- Opciq2(studentsMain,NumberStudents);
- break;
- }
- case 3:
- break;
- case 4:
- break;
- }
- } while (switcher != 5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement