Advertisement
Ahmet_Durmic

updateNR.2

Apr 27th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 21.70 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<string.h>
  4. #include<fstream>
  5. #include<conio.h>
  6. #include<windows.h>
  7.  
  8.  //Ahmet Durmic
  9.  //Harun Kaknjo
  10.  
  11. using namespace std;
  12.  
  13. int n,izbor,option;
  14. double m;//ukupni bodovi
  15. double um;//bodovi za prolaznost
  16. double _max=0;
  17. double _min=INT_MAX;
  18. double _max2=INT_MIN;
  19. int br=0;
  20. int br2=0;
  21.  
  22. void ispis(){
  23.     cout.width(85);
  24.     cout << "------------------------------------------------------------------------" << endl;
  25.     cout.width(25);
  26.     cout<< "\t\t\t\t    SIDE MENU" << endl ;
  27.     cout.width(85);
  28.     cout<< "------------------------------------------------------------------------" << endl;
  29.     cout << "             ID\tOPTION" << endl;
  30.     cout << "             1)\tStudent sa maksimalnim brojem bodova" << endl << "             2)\tStudent sa minimalnim brojem bodova" << endl;
  31.     cout << "             3)\tStudenti koji su polozili predmet"<<endl<<"             4)\tStudenti koji nisu polozili predmet"<<endl;
  32.     cout << "             5)\tSortiranji niz studenata po broju bodova"<<endl<<"             6)\tUnesi nove studente"<<endl<<"             7)\tIspisi podatake o studentu na osnovu unesenog predmeta i imena\n"<<"             8)\tSortirani niz studenata po broju bodova na osnovu unesenog predmeta\n"<<"             9)\tProlaznost[%]"<<endl;
  33.     cout << "             10)\ Main menu";
  34.    
  35. }
  36.  
  37. void cls(){
  38.     system("pause");
  39.     system("cls");
  40.     ispis();
  41. }
  42.  
  43. void main_menu(){
  44.     cout.width(85);
  45.     cout << "---------------------------------------------------------------------------" << endl;
  46.     cout.width(25);
  47.     cout<< "\t\t\t\tMAIN MENU" << endl ;
  48.     cout.width(85);
  49.     cout<< "----------------------------------------------------------------------------" << endl;
  50.     cout << "             ID\tOPTION" << endl;
  51.     cout << "             0)\tIspis unesenih studenata iz datoteke "<<endl;
  52.     cout << "             1)\tUnos studenata u datoteku" << endl << "             2)\tSIDE MENU" << endl;
  53.     cout << "             3)\tSacuvaj stanje i izadi "<<endl;
  54. }
  55.  
  56. void cls_main(){
  57.     system("pause");
  58.     system("cls");
  59.     main_menu();
  60. }
  61.  
  62. struct prosjek{
  63.     double pp,dp;//prva parcijala,druga parcijala
  64. };
  65.  
  66. struct pamtime{
  67.     char ime1[25],ime2[25];
  68. };
  69.  
  70. struct student{
  71.    
  72.     char predmet[30];
  73.     char ip[25];
  74.     prosjek unos;
  75.     pamtime pi;
  76.    
  77. };
  78.  
  79. void podaci_o_ispitu(){
  80.    
  81.     cout<<"----------------------------------------------------------------------\n";
  82.         cout<<"[UKUPNI BROJ BODOVA MORA BITI VECI OD 55% DA BI STUDENT POLOZIO ISPIT]\n\n";
  83.         cout<<"Unesite ukupan broj bodova [ 1.] i [ 2.] parcijalnog ispita:    ";
  84.         cin>>m;
  85.          while(!cin) {
  86.         cout << "Pogresan unos!.\nUnesite ukupan broj bodova [ 1.] i [ 2.] parcijalnog ispita: ";
  87.         cin.clear(); // Oporavak toka
  88.         cin.ignore(10000, '\n'); // Brisanje spremnika
  89.         cin >> m;
  90.     }
  91.         cout<<endl;
  92.         um=m/1.8;
  93.         cout<<"           [UKUPNI BROJ BODOVA MORA BITI VECI OD "<<um<<"]\n";
  94.         cout<<"----------------------------------------------------------------------\n";
  95.     cout<<endl;
  96.     cin.ignore(10000,'\n');cin.clear();
  97.    
  98. }
  99.  
  100. student unesi_podatke(){
  101.     student s;
  102.     cout<<"Unesite predmet: ";cin.getline(s.predmet,30);
  103.       while(!cin) {
  104.         cout << "Pogresan unos!.\nUnesite predmet: ";
  105.         cin.clear(); // Oporavak toka
  106.         cin.ignore(10000, '\n'); // Brisanje spremnika
  107.         cin.getline(s.predmet,30);
  108.     }
  109.    
  110.     podaci_o_ispitu();
  111.  
  112.     cout<<"Unesite ime i prezime: ";cin.getline(s.ip,25);
  113.      while(!cin) {
  114.         cout << "Pogresan unos!.\nUnesite ime i prezime: ";
  115.         cin.clear(); // Oporavak toka
  116.         cin.ignore(10000, '\n'); // Brisanje spremnika
  117.         cin.getline(s.ip,25);
  118.     }
  119.     cout<<"Unesite bodove sa [ 1.] parcijalnog ispita: ";cin>>s.unos.pp;
  120.     while(!cin||s.unos.pp>m/2) {
  121.         cout << "Pogresan unos!.\nUnesite bodove sa [ 1.] parcijalnog ispita: ";
  122.         cin.clear(); // Oporavak toka
  123.         cin.ignore(10000, '\n'); // Brisanje spremnika
  124.         cin>>s.unos.pp;
  125.     }
  126.     cout<<"Unesite bodove sa [ 2.] parcijalnog ispita: ";cin>>s.unos.dp;
  127.     while(!cin||s.unos.dp>m/2) {
  128.         cout << "Pogresan unos!.\nUnesite bodove sa [ 2.] parcijalnog ispita: ";
  129.         cin.clear(); // Oporavak toka
  130.         cin.ignore(10000, '\n'); // Brisanje spremnika
  131.         cin>>s.unos.dp;
  132.     }
  133.    // sacuvaj_stanje("s.dat",s);
  134.     return s;
  135. }
  136.  
  137. void ispisi_max(student A[],int a){
  138.     int maxI;
  139.     for(int i=0;i<a;i++){
  140.         if(A[i].unos.pp+A[i].unos.dp>_max){
  141.             _max=A[i].unos.pp+A[i].unos.dp;
  142.             strcpy(A->pi.ime1,A[i].ip);
  143.             br++;
  144.             for(int i=1;i<br;i++){
  145.                 if(i==br){
  146.                     maxI=i;
  147.                    strcpy(A->pi.ime1,A[maxI].ip);
  148.                 }  
  149.             }
  150.            
  151.         }
  152.        
  153.     }
  154.     cout<<"Student sa maximalnim brojem bodova je "<<A->pi.ime1<<" i ima ukupno ["<<_max<<"] bodova";
  155. }
  156.  
  157.  
  158. void ispisi_min(student A[],int a){
  159.     int minI;
  160.     for(int i=0;i<a;i++){
  161.         if(A[i].unos.pp+A[i].unos.dp<_min){
  162.             _min=A[i].unos.pp+A[i].unos.dp;
  163.             strcpy(A->pi.ime2,A[i].ip);
  164.             br2++;
  165.             for(int i=1;i<br2;i++){
  166.                 if(i==br2){
  167.                     minI=i;
  168.                     strcpy(A->pi.ime2,A[minI].ip);
  169.                 }
  170.                
  171.             }
  172.            
  173.         }
  174.     }
  175.     cout<<"Student sa minimalnim brojem bodova je "<<A->pi.ime2<<" i ima ukupno ["<<_min<<"] bodova";
  176. }
  177.  
  178.  
  179. void ispisi_polozili(student A[],int a){
  180.     int br1=0;
  181.     int br2=0;
  182.     cout<<"Studenti koji su zadovoljili kriterije su\n ";
  183.     for(int i=0;i<a;i++){
  184.         if(A[i].unos.pp+A[i].unos.dp>um){
  185.             br1++;
  186.             cout<<i+1<<". "<<A[i].ip<<endl;
  187.         }else{
  188.             br2++;
  189.             if(br2==a){
  190.                 cout<<"[Niti jedan student nije zadovoljio ocekivani kriteriji]"<<endl;
  191.             }
  192.            
  193.         }
  194.     }
  195. }
  196.  
  197. void ispisi_nisupolozili(student A[],int a){
  198.     int br1=0;
  199.     int br2=0;
  200.     cout<<"Studenti koji nisu zadovoljili kriterije su\n ";
  201.     for(int i=0;i<a;i++){
  202.         if(A[i].unos.pp+A[i].unos.dp<um){
  203.             br1++;
  204.             cout<<i+1<<". "<<A[i].ip<<endl;
  205.         }else{
  206.             br2++;
  207.             if(br2==a){
  208.                 cout<<"[Svi studenti su zadovoljili ocekivane kriterije]"<<endl;
  209.             }
  210.         }
  211.        
  212.     }
  213. }
  214. void rotiraj(student &x,student &y){
  215.     student temp=x;
  216.     x=y;
  217.     y=temp;
  218. }
  219. void sortiraj(student A[],int a){
  220.     for(int i=0;i<a-1;i++){
  221.         for(int j=0;j<a-1;j++){
  222.             if((A[j].unos.pp+A[j].unos.dp)<(A[j+1].unos.pp+A[j+1].unos.dp)){
  223.                 rotiraj(A[j],A[j+1]);
  224.             }
  225.         }
  226.     }
  227. }
  228. void ispisi_sortirano(student A[],int a){
  229.     sortiraj(A,a);
  230.         cout<<"==================================================================\n";
  231.         for(int i=0;i<a;i++){
  232.             cout<<" "<<i+1<<".       "<<A[i].ip<<" - "<<" PREDMET "<<"["<<A[i].predmet<<"]"<<"   "<<(A[i].unos.pp+A[i].unos.dp)<<" [BODA]"<<endl;
  233.         }
  234.         cout<<"==================================================================\n";
  235. }
  236.  
  237.  
  238. void ispisi_prolaznost(student A[], int a){
  239.     float prolaznost;
  240.     float br3=0;
  241.     for(int i=0;i<a;i++){
  242.         if(A[i].unos.pp+A[i].unos.dp>um){
  243.             br3++;
  244.         }
  245.        
  246.     }
  247.     prolaznost=(br3/a)*100;
  248.     cout <<"Prolaznost iznosi ["<<prolaznost<<"%]";
  249. }
  250.  
  251.  
  252. void ispisi_studenta(student A){
  253.     cout<<"==============================================\n";
  254.     cout<<"\t"<<A.ip<<"   "<<(A.unos.pp+A.unos.dp)<<" [BODOVA]"<<endl;
  255.     cout<<"==============================================\n";
  256. }
  257.  
  258. void pretraga_po_imenu(student *A, char *B, int a){
  259.     student uneseni;
  260.     for(int i=0;i<a;i++){
  261.         if(stricmp((A+i)->ip,B)==0){
  262.             uneseni=A[i];
  263.         }
  264.     }
  265.     ispisi_studenta(uneseni);
  266. }
  267.  
  268.  
  269. void pretraga_po_predmetu(student *A, char *B, int a){
  270.     student predmet;
  271.     for(int i=0;i<a;i++){
  272.         if(stricmp((A+i)->predmet,B)==0){
  273.             predmet=A[i];
  274.         }
  275.     }
  276. }
  277.  
  278. void pretraga_po_predmetu_isti_predmet(student *A, char *B, int a){
  279.     student predmet2;
  280.     cout<<"=====================================\n";
  281.     for(int i=0;i<a;i++){
  282.         if(stricmp((A+i)->predmet, B)==0){
  283.             predmet2 = A[i];
  284.             cout<<" "<<predmet2.ip<<"   "<<(predmet2.unos.pp+predmet2.unos.dp)<<" [BODOVA]"<<endl;
  285.            
  286.         }
  287.     }
  288.     cout<<"=====================================\n";
  289. }
  290.  
  291. void spisak_unesenih_predmeta(student *A,int a){
  292.     cout<<"    Spisak unesenih predmeta\n";
  293.     cout<<"=================================\n";
  294.     for(int i=0;i<a;i++){
  295.             cout<<"\t    "<<(A+i)->predmet<<endl;
  296.         }
  297.        
  298.     cout<<"=================================\n";
  299. }
  300.  
  301. void sacuvaj_stanje(student s[], int n){
  302.    
  303.     std::ofstream _broj("broj_prijava.dat", std::ios::binary);
  304.     _broj.write(reinterpret_cast<char*>(&n), sizeof(int));
  305.     _broj.close();
  306.        
  307.        
  308.     std::ofstream pisanje("studenti.dat", std::ios::binary);
  309.     for(int i(0); i<n; ++i){
  310.     pisanje.write(reinterpret_cast<char*>(&s[i]), sizeof(student));    
  311.     }
  312.     pisanje.close();
  313.    
  314. }
  315.  
  316.  
  317.  
  318. int main(){
  319. cout<<endl;
  320.  
  321.     int brMAIN=0;// Brojac za unos 1
  322.     int brMAIN2=0;//Brojac za provjeru stanja datoteke
  323.    
  324.  
  325.     std::ifstream broj("broj_prijava.dat", std::ios::binary);
  326.    
  327.     n=0;
  328.     if(!broj){
  329.         Sleep(1);
  330.     } else{
  331.         broj.read(reinterpret_cast<char*>(&n), sizeof(int));  
  332.         broj.close();
  333.     }
  334.    
  335.     student s[30];
  336.     std::ifstream citanje("studenti.dat", std::ios::binary);
  337.        
  338.     citanje.seekg(0, std::ios::end);
  339.     if (citanje.tellg() == 0){
  340.        
  341.     }else{
  342.         brMAIN2++;
  343.     }
  344.     citanje.seekg(0, std::ios::beg);
  345.    
  346.     for(int i(0); i<n; ++i){
  347.         citanje.read(reinterpret_cast<char*>(&s[i]), sizeof(student));  
  348.     }
  349.    
  350.     citanje.close();
  351.    
  352.    
  353.             cls_main();
  354.             cout << endl << "---Odaberite opciju: "; cin >> option;cout<<endl;
  355.             while(!cin||option>3) {
  356.             cout << "Pogresan unos!. Unesite broj: ";
  357.             cin.clear(); // Oporavak toka
  358.             cin.ignore(10000, '\n'); // Brisanje spremnika
  359.             cin >> option;
  360.              }
  361.              
  362.             cin.clear();cin.ignore(10000,'\n');
  363.             system("cls");
  364.                    
  365.     do{
  366.        
  367.         if(option==0){
  368.      
  369.             ispisi_sortirano(s,n);
  370.         cout<<endl;
  371.             cls_main();
  372.         cout << endl << "---Odaberite opciju: "; cin >> option;cout<<endl;
  373.              while(!cin||option>3) {
  374.             cout << "Pogresan unos!. Unesite broj: ";
  375.             cin.clear(); // Oporavak toka
  376.             cin.ignore(10000, '\n'); // Brisanje spremnika
  377.             cin >> option;
  378.              }
  379.             cin.clear();cin.ignore(10000,'\n');
  380.             system("cls");
  381.         }
  382.      
  383. ///////////////////////////////////////////////////////////////////////
  384.  
  385.         if(option==1){
  386.            
  387.             if(brMAIN>=1||brMAIN2>=1){
  388.                 cout<<"=========================================================\n";
  389.                 cout <<"Opcija nije moguca, iz sigurnosnih razloga za dodavanje \n novih studenata pritisnite opciju 2 zatim opciju 6"<<endl;
  390.                 cout<<"=========================================================\n";
  391.             }else{
  392.            
  393.         cout<<"==========================\n";
  394.         cout<<"Unesite broj studenata: ";
  395.         cin>>n;
  396.          while(!cin) {
  397.             cout << "Pogresan unos!. Unesite broj studenata: ";
  398.             cin.clear(); // Oporavak toka
  399.             cin.ignore(10000, '\n'); // Brisanje spremnika
  400.             cin >> n;
  401.             }
  402.        cout<<"==========================\n";
  403.        cin.clear();cin.ignore(10000,'\n');
  404.         for(int i=0;i<n;i++){
  405.             system("cls");
  406.             cout<<"Unesite podatke o "<<i+1<<". studentu\n";
  407.             s[i]=unesi_podatke();
  408.             cin.clear();cin.ignore(10000,'\n');
  409.             cout<<endl;
  410.          }
  411.          sacuvaj_stanje(s,n);
  412.        
  413.         }
  414.         brMAIN++;
  415.             cls_main();
  416.         cout << endl << "---Odaberite opciju: "; cin >> option;cout<<endl;
  417.              while(!cin||option>3) {
  418.             cout << "Pogresan unos!. Unesite broj: ";
  419.             cin.clear(); // Oporavak toka
  420.             cin.ignore(10000, '\n'); // Brisanje spremnika
  421.             cin >> option;
  422.              }
  423.             cin.clear();cin.ignore(10000,'\n');
  424.            
  425.             system("cls");
  426.        
  427.                
  428.            
  429.         }
  430.        
  431. ////////////////////////////////////////////////////////////////////////
  432.  
  433.         if(option==2){
  434.             cls();
  435.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  436.             while(!cin||izbor>10) {
  437.             cout << "Pogresan unos!. Unesite broj: ";
  438.             cin.clear(); // Oporavak toka
  439.             cin.ignore(10000, '\n'); // Brisanje spremnika
  440.             cin >> izbor;
  441.             }
  442.              cin.ignore(10000,'\n');cin.clear();
  443.             system("cls");
  444.            
  445.            
  446.     do{
  447.        
  448.         if(izbor==1){
  449.         system("cls");
  450.         ispisi_max(s,n);
  451.         cout<<endl;
  452.             cls();
  453.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  454.              while(!cin||izbor>10) {
  455.             cout << "Pogresan unos!. Unesite broj: ";
  456.             cin.clear(); // Oporavak toka
  457.             cin.ignore(10000, '\n'); // Brisanje spremnika
  458.             cin >> izbor;
  459.              }
  460.             cin.clear();cin.ignore(10000,'\n');
  461.             system("cls");
  462.         }
  463.        
  464. ////////////////////////////////////////////////////////////////////////
  465.  
  466.         if(izbor==2){
  467.             system("cls");
  468.             ispisi_min(s,n);
  469.         cout<<endl;
  470.             cls();
  471.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  472.              while(!cin||izbor>10) {
  473.             cout << "Pogresan unos!. Unesite broj: ";
  474.             cin.clear(); // Oporavak toka
  475.             cin.ignore(10000, '\n'); // Brisanje spremnika
  476.             cin >> izbor;
  477.              }
  478.             cin.clear();cin.ignore(10000,'\n');
  479.             system("cls");
  480.         }
  481.        
  482. ////////////////////////////////////////////////////////////////////////
  483.  
  484.         if(izbor==3){
  485.             system("cls");
  486.             ispisi_polozili(s,n);
  487.         cout<<endl;
  488.             cls();
  489.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  490.              while(!cin||izbor>10) {
  491.             cout << "Pogresan unos!. Unesite broj: ";
  492.             cin.clear(); // Oporavak toka
  493.             cin.ignore(10000, '\n'); // Brisanje spremnika
  494.             cin >> izbor;
  495.              }
  496.             cin.clear();cin.ignore(10000,'\n');
  497.             system("cls");
  498.         }
  499.        
  500. ////////////////////////////////////////////////////////////////////////
  501.  
  502.         if(izbor==4){
  503.             system("cls");
  504.             ispisi_nisupolozili(s,n);
  505.         cout<<endl;
  506.             cls();
  507.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  508.              while(!cin||izbor>10) {
  509.             cout << "Pogresan unos!. Unesite broj: ";
  510.             cin.clear(); // Oporavak toka
  511.             cin.ignore(10000, '\n'); // Brisanje spremnika
  512.             cin >> izbor;
  513.              }
  514.             cin.clear();cin.ignore(10000,'\n');
  515.             system("cls");
  516.         }
  517.        
  518. ////////////////////////////////////////////////////////////////////////
  519.  
  520.         if(izbor==5){
  521.             system("cls");
  522.             ispisi_sortirano(s,n);
  523.         cout<<endl;
  524.             cls();
  525.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  526.              while(!cin||izbor>10) {
  527.             cout << "Pogresan unos!. Unesite broj: ";
  528.             cin.clear(); // Oporavak toka
  529.             cin.ignore(10000, '\n'); // Brisanje spremnika
  530.             cin >> izbor;
  531.              }
  532.             cin.clear();cin.ignore(10000,'\n');
  533.             system("cls");
  534.         }
  535.        
  536. ////////////////////////////////////////////////////////////////////////
  537.  
  538.         if(izbor==6){
  539.            
  540.             system("cls");
  541.             cout<<"Unesite podatke o novom studentu:\n";
  542.             s[n]=unesi_podatke();
  543.             n=n+1;
  544.             sacuvaj_stanje(s,n);
  545.         cout<<endl;
  546.             cls();
  547.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  548.              while(!cin||izbor>10) {
  549.             cout << "Pogresan unos!. Unesite broj: ";
  550.             cin.clear(); // Oporavak toka
  551.             cin.ignore(10000, '\n'); // Brisanje spremnika
  552.             cin >> izbor;
  553.              }
  554.             cin.clear();cin.ignore(10000,'\n');
  555.             system("cls");
  556.         }
  557.        
  558. ////////////////////////////////////////////////////////////////////////
  559.  
  560.         if(izbor==7){
  561.             int pred=0;
  562.             int im=-1;
  563.             system("cls");
  564.             char pretraga[25];
  565.             char clas[30];
  566.             spisak_unesenih_predmeta(s,n);
  567.             cout<<"Unesite predmet: ";
  568.             cin.getline(clas,30);
  569.             for(int i=0;i<n;i++){
  570.                 if(stricmp( (s+i)->predmet,clas )!=0){
  571.      
  572.                 }else{
  573.                     pred++;
  574.                 }
  575.             }
  576.             while(pred<1){
  577.                 pred = 0;
  578.                 cout<<"[Unijeli ste nepostojeci predmet]\nUnesite predmet: ";
  579.                     cin.getline(clas,30);
  580.                  for(int i=0;i<n;i++){
  581.                 if(stricmp( (s+i)->predmet,clas )!=0){
  582.      
  583.                 }else{
  584.                     pred++;
  585.                 }
  586.             }
  587.                
  588.         }
  589.        
  590.             pretraga_po_predmetu(s, clas, n);
  591.             cout <<"Unesite ime za ispis: ";
  592.             cin.getline(pretraga,25);
  593.             for(int i=0;i<n;i++){
  594.                 if(stricmp( (s+i)->ip,pretraga )==0){
  595.                     im++;
  596.                 }else{
  597.                    
  598.                 }
  599.             }
  600.             while(im==-1){
  601.                 im = -1;
  602.                 cout<<"[Unijeli ste nepostojece ime]\nUnesite ime za ispis: ";
  603.                     cin.getline(pretraga,25);
  604.                  for(int i=0;i<n;i++){
  605.                 if(stricmp( (s+i)->ip,pretraga )==0){
  606.                     im++;
  607.                 }else{
  608.                
  609.                 }
  610.             }
  611.                
  612.         }
  613.        
  614.             pretraga_po_imenu(s, pretraga, n);
  615.         cout<<endl;
  616.             cls();
  617.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  618.              while(!cin||izbor>10) {
  619.             cout << "Pogresan unos!. Unesite broj: ";
  620.             cin.clear(); // Oporavak toka
  621.             cin.ignore(10000, '\n'); // Brisanje spremnika
  622.             cin >> izbor;
  623.              }
  624.             cin.clear();cin.ignore(10000,'\n');
  625.             system("cls");
  626.         }
  627.        
  628. ////////////////////////////////////////////////////////////////////////
  629.  
  630.         if(izbor==8){
  631.             int pred=0;
  632.             system("cls");
  633.             char clas2[30];
  634.             system("cls");
  635.             spisak_unesenih_predmeta(s,n);
  636.             cout<<"Unesite predmet: ";
  637.             cin.getline(clas2,30);
  638.            for(int i=0;i<n;i++){
  639.                 if(stricmp( (s+i)->predmet,clas2 )!=0){
  640.      
  641.                 }else{
  642.                     pred++;
  643.                 }
  644.             }
  645.             while(pred<1){
  646.                 pred = 0;
  647.                 cout<<"[Unijeli ste nepostojeci predmet]\nUnesite predmet: ";
  648.                     cin.getline(clas2,30);
  649.                  for(int i=0;i<n;i++){
  650.                 if(stricmp( (s+i)->predmet,clas2 )!=0){
  651.      
  652.                 }else{
  653.                     pred++;
  654.                 }
  655.             }
  656.                
  657.         }
  658.            
  659.             sortiraj(s,n);
  660.             pretraga_po_predmetu_isti_predmet(s,clas2,n);
  661.         cout<<endl;
  662.              cls();
  663.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  664.              while(!cin||izbor>10) {
  665.             cout << "Pogresan unos!. Unesite broj: ";
  666.             cin.clear(); // Oporavak toka
  667.             cin.ignore(10000, '\n'); // Brisanje spremnika
  668.             cin >> izbor;
  669.              }
  670.             cin.clear();cin.ignore(10000,'\n');
  671.             system("cls");
  672.         }
  673.        
  674. ////////////////////////////////////////////////////////////////////////
  675.  
  676.         if(izbor==9){
  677.             system("cls");
  678.             ispisi_prolaznost(s,n);
  679.         cout<<endl;
  680.             cls();
  681.         cout << endl << "---Odaberite opciju: "; cin >> izbor;cout<<endl;
  682.              while(!cin||izbor>10) {
  683.             cout << "Pogresan unos!. Unesite broj: ";
  684.             cin.clear(); // Oporavak toka
  685.             cin.ignore(10000, '\n'); // Brisanje spremnika
  686.             cin >> izbor;
  687.              }
  688.             cin.clear();cin.ignore(10000,'\n');
  689.             system("cls");    
  690.         }
  691.        
  692. ////////////////////////////////////////////////////////////////////////
  693.  
  694.         if(izbor==10){
  695.             cls_main();
  696.             cout << endl << "---Odaberite opciju: "; cin >> option;cout<<endl;
  697.             while(!cin||option>3) {
  698.             cout << "Pogresan unos!. Unesite broj: ";
  699.             cin.clear(); // Oporavak toka
  700.             cin.ignore(10000, '\n'); // Brisanje spremnika
  701.             cin >> option;
  702.             }
  703.             cin.clear();cin.ignore(10000,'\n');
  704.             system("cls");
  705.             }
  706.        
  707.         } while(izbor!=10);
  708.                    
  709.     }
  710.        
  711. }while(option!=3);
  712.    
  713.     sacuvaj_stanje(s,n);                  
  714.    
  715.    
  716.     system("pause");
  717.     return 0;
  718. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement