Phoenix_x

Untitled

Dec 19th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.30 KB | None | 0 0
  1. // ConsoleApplication33.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6.  
  7. #include<iostream>
  8. #include<string>
  9. using namespace std;
  10. int n;
  11. struct student
  12. {
  13.     long fn;
  14.     char name[30];
  15.     int ar[6];
  16. };
  17.  
  18. void vhod(student st[])
  19. {
  20.     int i, z;
  21.     do
  22.     {
  23.         cout << "\n Kolko studenti: ";
  24.         cin >> n;
  25.     } while (n<1 || n>25);
  26.     for (i = 0; i<n; i++)
  27.     {
  28.         cout << "\n FN: ";
  29.         cin >> st[i].fn;
  30.         cout << "\n Ime: ";
  31.         cin >> st[i].name;
  32.         cout << "\n Vuvedete tochki ot 30 do 100 za vsichki specialnosti";
  33.         for (z = 0; z<6; z++)
  34.         {
  35.             do
  36.             {
  37.                 cout << "\n Vuvedete tochki za " << z + 1 << "-ta specialnost:";
  38.                 cin >> st[i].ar[z];
  39.                 if (st[i].ar[z]<30 || st[i].ar[z]>100)
  40.                     cout << "\n Greshen vhod";
  41.             } while (st[i].ar[z]<30 || st[i].ar[z]>100);
  42.         }
  43.     }
  44. }
  45.  
  46. void convert(student st[])
  47. {
  48.     int i, z;
  49.     for (i = 0; i<n; i++)
  50.     {
  51.         for (z = 0; z<6; z++)
  52.         {
  53.             if (st[i].ar[z] >= 30 && st[i].ar[z] <= 49)
  54.                 st[i].ar[z] = 2;
  55.             else if (st[i].ar[z] >= 50 && st[i].ar[z] <= 61)
  56.                 st[i].ar[z] = 3;
  57.             else if (st[i].ar[z] >= 62 && st[i].ar[z] <= 74)
  58.                 st[i].ar[z] = 4;
  59.             else if (st[i].ar[z] >= 75 && st[i].ar[z] <= 88)
  60.                 st[i].ar[z] = 5;
  61.             else if (st[i].ar[z] >= 89 && st[i].ar[z] <= 100)
  62.                 st[i].ar[z] = 6;
  63.         }
  64.     }
  65. }
  66.  
  67. void otlichnici(student st[])
  68. {
  69.     int i;
  70.     double s;
  71.     for (i = 0; i<n; i++)
  72.     {
  73.         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;
  74.         if (s >= 5.5)
  75.         {
  76.             cout << endl << "  " << st[i].fn << "\t" << st[i].name << endl;
  77.         }
  78.     }
  79. }
  80.  
  81. void search(student st[])
  82. {
  83.     int i, z;
  84.     string input;
  85.     long fn1;
  86.     cout << "\n Tursene po FN:";
  87.     cin >> fn1;
  88.     for (i = 0; i<25; i++)
  89.     {
  90.         if (st[i].fn == fn1)
  91.         {
  92.             cout << endl << "  " << st[i].fn << "\t" << st[i].name << endl;
  93.             for (z = 0; z<6; z++)
  94.             {
  95.                 cout << st[i].ar[z] << endl;
  96.             }
  97.         }
  98.         else if (st[i].fn != fn1)
  99.         {
  100.             cout << "\n Nqma nameren student s tozi FN";
  101.             cout << "\n Iskate li da dobavite nov student?" << endl << "Da ili Ne?" << endl;
  102.             cin >> input;
  103.             if (input == "Da" || input == "da")
  104.             {
  105.                 do
  106.                 {
  107.                     cout << "\n FN: ";
  108.                     cin >> st[i + 1].fn;
  109.                     cout << "\n Ime: ";
  110.                     cin >> st[i + 1].name;
  111.                     cout << "\n Vuvedete tochki ot 30 do 100 za vsichki specialnosti";
  112.                     for (z = 0; z<6; z++)
  113.                     {
  114.                         do
  115.                         {
  116.                             cout << "\n Vuvedete tochki za " << z + 1 << "-ta specialnost:";
  117.                             cin >> st[i + 1].ar[z];
  118.                             if (st[i + 1].ar[z]<30 || st[i + 1].ar[z]>100)
  119.                                 cout << "\n Greshen vhod";
  120.                         } while (st[i + 1].ar[z]<30 || st[i + 1].ar[z]>100);
  121.                     }
  122.                 } while (n<1 || n>25);
  123.             }
  124.             else if (input == "Ne" || input == "ne")
  125.             {
  126.                 return; //край на функцията и връщане отново в main
  127.             }
  128.         }
  129.     }
  130. }
  131.  
  132. void main()
  133. {
  134.     int ch;
  135.     student st[25];
  136.     do
  137.     {
  138.         cout << "\n 1.Input Student";
  139.         cout << "\n 2.Convert the points to grades";
  140.         cout << "\n 3.List students with average exelent grade";
  141.         cout << "\n 4.Search by Fnumber";
  142.         cout << "\n 5.Exit";
  143.         do
  144.         {
  145.             cout << "\n Your choise is: ";
  146.             cin >> ch;
  147.         } while (ch<1 || ch>5);
  148.         switch (ch)
  149.         {
  150.         case 1: vhod(st); break;
  151.         case 2: convert(st); break;
  152.         case 3: otlichnici(st); break;
  153.         case 4: search(st); break;
  154.         }
  155.     } while (ch != 5);
  156. }
Advertisement
Add Comment
Please, Sign In to add comment