SHARE
TWEET

Untitled

a guest Jun 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct student
  4. {
  5.     string ime;
  6.     string prezime;
  7.     string familia;
  8.     int nomer;
  9.     double ocenki[];
  10.     double izvineni;
  11.     double neizvineni;
  12. }a[100];
  13. struct sredenuspeh
  14. {
  15.     string name;
  16.     string prez;
  17.     string family;
  18.     double sredenu;
  19.     int nomer;
  20. }b[100];
  21. void vuvedi(student &s,int n)
  22. {
  23.          cin.ignore();
  24.          cout<<"Ime"<<endl;
  25.         getline(cin,s.ime);
  26.         cout<<"Prezime"<<endl;
  27.         getline(cin,s.prezime);
  28.         cout<<"Familia"<<endl;
  29.         cin>>s.familia;
  30.         cout<<"Nomer v klasa"<<endl;
  31.         cin>>s.nomer;
  32.         cout<<"Izvineni otsustviq"<<endl;
  33.         cin>>s.izvineni;
  34.         cout<<"Neizvineni otsustviq"<<endl;
  35.         cin>>s.neizvineni;
  36. }
  37. void create(ofstream &f,int n)
  38. {
  39.         student s;
  40.     char ch;
  41.     cout<<"shte vuvejdash li y/n ";
  42.     cin>>ch;
  43.     while(ch=='y')
  44.     {
  45.         vuvedi(s,n);
  46.         f<<s.ime<<endl<<s.prezime<<endl<<s.familia<<endl<<s.nomer<<endl<<s.izvineni<<endl<<s.neizvineni<<endl;
  47.         cout<<"Ocenki"<<endl;
  48.             for(int i=0;i<n;i++)
  49.              {int x; cin>>x; f<<x<<endl;}
  50.          cout<<"shte vuvejdash li y/n "<<endl;
  51.     cin>>ch;
  52.     }
  53. }
  54. void dobavi(fstream &f,int n)
  55. {
  56.     student s;
  57.     vuvedi(s,n);
  58.             f<<s.ime<<endl<<s.prezime<<endl<<s.familia<<endl<<s.nomer<<endl<<s.izvineni<<endl<<s.neizvineni<<endl;
  59. cout<<"Ocenki"<<endl;
  60.                     for(int i=0;i<n;i++)
  61.              {int x; cin>>x; f<<x<<endl;}
  62. }
  63. void sreden(ifstream &f,int n)
  64. {
  65.     student s;
  66. sredenuspeh sr[90];
  67.     int j=0;
  68.     cout<<true;
  69.     while(!f.eof())
  70.     {
  71.         double p=0;
  72.  
  73.         f>>s.ime>>s.prezime>>s.familia>>s.nomer>>s.izvineni>>s.neizvineni;
  74.                     for(int i=0;i<n;i++){int o;f>>o; p=p+o;}
  75.                     f>>ws;
  76.  
  77.              p=p/n;
  78.  
  79.          sr[j].name=s.ime;
  80.          sr[j].prez=s.prezime;
  81.          sr[j].family=s.familia;
  82.          sr[j].nomer=s.nomer;
  83.          sr[j].sredenu=p;
  84.  
  85.          j++;
  86.     }
  87.     for(int i=0;i<=j-1;i++)
  88.         for(int k=i+1;k<=j;k++)
  89.     {
  90.         if(sr[i].sredenu<sr[k].sredenu) swap(sr[i],sr[k]);
  91.     }
  92.  
  93.     cout<<endl;
  94.     cout<<"Nomer___Ime_________________sreden uspeh"<<endl;
  95.     for(int i=0;i<=j;i++)
  96.     {
  97.         cout<<"  "<<sr[i].nomer<<"     "<<sr[i].name<<"  "<<sr[i].prez<<"  "<<sr[i].family<<"           "<<sr[i].sredenu<<endl;
  98.     }
  99.  
  100. }
  101. void neizv(ifstream &f,ofstream &g,int n,int nei)
  102. {
  103.     student s;
  104.     while(!f.eof())
  105.     {
  106.                 f>>s.ime>>s.prezime>>s.familia>>s.nomer>>s.izvineni>>s.neizvineni;
  107.                     for(int i=0;i<n;i++){int o;f>>o; }
  108. f>>ws;
  109.                     if(s.neizvineni>=nei)
  110.                     {
  111.                         g<<s.ime<<endl<<s.prezime<<endl<<s.familia<<endl<<s.neizvineni<<endl;
  112.                     }
  113.     }
  114.  
  115. }
  116. int main()
  117. {
  118. int k;
  119. int n;
  120. cout<<"Kolko ocenki sthe ima vseki uchenik?"<<endl;
  121.         cin>>n;
  122. do{
  123.     cout<<"1-create file \n2-dobavqne na uchenik \n3-izvejdane na sreden uspeh v nizhodqsth red \n4-prepisva v drug file uchenicite s nad opredelen broy neizvineni A \n5-exit \n";
  124.     cin>>k;
  125.     switch(k)
  126.     {
  127.         case 1: {
  128.             ofstream f("Student.txt",ios::out);
  129.         create(f,n);
  130.         f.close(); };break;
  131.         case 2: {fstream f("Student.txt",ios::app);
  132.          dobavi(f,n);
  133.          f.close();}break;
  134.         case 3: {ifstream f("Student.txt",ios::in);
  135.          sreden(f,n);
  136.          f.close();}break;
  137.        case 4: {ifstream f("Student.txt",ios::in);
  138.         ofstream g("AmiSega.txt",ios::out);
  139.         cout<<"Vuvedi nad kolko neizvineni"<<endl;
  140.         int nei;
  141.         cin>>nei;
  142.         neizv(f,g,n,nei);
  143.          f.close();
  144.          g.close();}break;
  145.     }} while(k!=5);
  146.  
  147. return 0;}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top