Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication33.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include<iostream>
- #include<string>
- using namespace std;
- int n;
- struct student
- {
- long fn;
- char name[30];
- int ar[6];
- };
- void vhod(student st[])
- {
- int i, z;
- do
- {
- cout << "\n Kolko studenti: ";
- cin >> n;
- } while (n<1 || n>25);
- for (i = 0; i<n; i++)
- {
- cout << "\n FN: ";
- cin >> st[i].fn;
- cout << "\n Ime: ";
- cin >> st[i].name;
- cout << "\n Vuvedete tochki ot 30 do 100 za vsichki specialnosti";
- for (z = 0; z<6; z++)
- {
- do
- {
- cout << "\n Vuvedete tochki za " << z + 1 << "-ta specialnost:";
- cin >> st[i].ar[z];
- if (st[i].ar[z]<30 || st[i].ar[z]>100)
- cout << "\n Greshen vhod";
- } while (st[i].ar[z]<30 || st[i].ar[z]>100);
- }
- }
- }
- void convert(student st[])
- {
- int i, z;
- for (i = 0; i<n; i++)
- {
- for (z = 0; z<6; z++)
- {
- if (st[i].ar[z] >= 30 && st[i].ar[z] <= 49)
- st[i].ar[z] = 2;
- else if (st[i].ar[z] >= 50 && st[i].ar[z] <= 61)
- st[i].ar[z] = 3;
- else if (st[i].ar[z] >= 62 && st[i].ar[z] <= 74)
- st[i].ar[z] = 4;
- else if (st[i].ar[z] >= 75 && st[i].ar[z] <= 88)
- st[i].ar[z] = 5;
- else if (st[i].ar[z] >= 89 && st[i].ar[z] <= 100)
- st[i].ar[z] = 6;
- }
- }
- }
- void otlichnici(student st[])
- {
- int i;
- double s;
- for (i = 0; i<n; i++)
- {
- s = double(st[i].ar[0] + st[i].ar[1] + st[i].ar[2] + st[i].ar[3] + st[i].ar[4] + st[i].ar[5]) / 6;
- if (s >= 5.5)
- {
- cout << endl << " " << st[i].fn << "\t" << st[i].name << endl;
- }
- }
- }
- void search(student st[])
- {
- int i, z;
- string input;
- long fn1;
- cout << "\n Tursene po FN:";
- cin >> fn1;
- for (i = 0; i<25; i++)
- {
- if (st[i].fn == fn1)
- {
- cout << endl << " " << st[i].fn << "\t" << st[i].name << endl;
- for (z = 0; z<6; z++)
- {
- cout << st[i].ar[z] << endl;
- }
- }
- else if (st[i].fn != fn1)
- {
- cout << "\n Nqma nameren student s tozi FN";
- cout << "\n Iskate li da dobavite nov student?" << endl << "Da ili Ne?" << endl;
- cin >> input;
- if (input == "Da" || input == "da")
- {
- do
- {
- cout << "\n FN: ";
- cin >> st[i + 1].fn;
- cout << "\n Ime: ";
- cin >> st[i + 1].name;
- cout << "\n Vuvedete tochki ot 30 do 100 za vsichki specialnosti";
- for (z = 0; z<6; z++)
- {
- do
- {
- cout << "\n Vuvedete tochki za " << z + 1 << "-ta specialnost:";
- cin >> st[i + 1].ar[z];
- if (st[i + 1].ar[z]<30 || st[i + 1].ar[z]>100)
- cout << "\n Greshen vhod";
- } while (st[i + 1].ar[z]<30 || st[i + 1].ar[z]>100);
- }
- } while (n<1 || n>25);
- }
- else if (input == "Ne" || input == "ne")
- {
- return; //край на функцията и връщане отново в main
- }
- }
- }
- }
- void main()
- {
- int ch;
- student st[25];
- do
- {
- cout << "\n 1.Input Student";
- cout << "\n 2.Convert the points to grades";
- cout << "\n 3.List students with average exelent grade";
- cout << "\n 4.Search by Fnumber";
- cout << "\n 5.Exit";
- do
- {
- cout << "\n Your choise is: ";
- cin >> ch;
- } while (ch<1 || ch>5);
- switch (ch)
- {
- case 1: vhod(st); break;
- case 2: convert(st); break;
- case 3: otlichnici(st); break;
- case 4: search(st); break;
- }
- } while (ch != 5);
- }
Advertisement
Add Comment
Please, Sign In to add comment