Advertisement
thouxanbanuno

13

Dec 8th, 2019
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.     struct element
  5.     {
  6.         string f;
  7.         string io;
  8.         string obsh;
  9.         double res;
  10.         element *next;
  11.     };
  12.     int main(){
  13.     element *beg, *help,*last;
  14.     int manip1=1, manip2=1, manip3=1,manip4=1;
  15.     int n;
  16.     cin>>n;
  17.     beg=new element;
  18.     last=beg;
  19.     for(int i=0; i<n; i++){
  20.         help=new element;
  21.         cin>>help->f>>help->io>>help->obsh>>help->res;
  22.         if(help->f.size()>manip1){
  23.             manip1=help->f.size();
  24.         }
  25.         if(help->io.size()>manip2){
  26.             manip2=help->io.size();
  27.         }
  28.         if(help->obsh.size()>manip4){
  29.             manip4=help->obsh.size();
  30.         }
  31.         int cp=help->res;
  32.         int c=0;
  33.         while(cp){
  34.             cp/=10;
  35.             c++;
  36.         }
  37.         if(c>manip3)
  38.             manip3=c;
  39.  
  40.         last->next=help;
  41.         last=help;
  42.     }
  43.     last->next=0;
  44.  
  45.     ///Punkt a
  46.     string usl;
  47.     cin>>usl;
  48.     int mx=1e9;
  49.     element *ans;
  50.  
  51.     help=beg->next;
  52.     while(help){
  53.         if(help->f==usl && mx>help->res){
  54.             ans=help;
  55.             mx=help->res;
  56.         }
  57.         help=help->next;
  58.     }
  59.     cout<<endl<<"a)"<<endl;
  60.     cout<<ans->f<<' '<<ans->io<<' '<<ans->obsh<<' '<<ans->res<<endl<<endl<<"b)"<<endl;
  61.     help=beg->next;
  62.     while(help){
  63.         element *help2=help->next;
  64.         while(help2){
  65.             if(help2 && help->f > help2->f){
  66.             string s1=help->f,s2=help->io,s3=help->obsh;
  67.             double s4=help->res;
  68.             help->f=help2->f;
  69.             help->io=help2->io;
  70.             help->res=help2->res;
  71.             help->obsh=help2->obsh;
  72.             help2->f=s1;
  73.             help2->io=s2;
  74.             help2->res=s4;
  75.             help2->obsh=s3;
  76.             }
  77.             help2=help2->next;
  78.         }
  79.         help=help->next;
  80.     }
  81.     cin>>usl;
  82.  //   cout<<manip1<<' '<<manip2<<' '<<manip3<<endl;
  83.     help=beg->next;
  84.     while(help){
  85.         if(help->obsh==usl)
  86.             cout<<setw(manip1)<<help->f<<' '<<setw(manip2)<<help->io<<' '<<setw(manip4)<<help->obsh<<' '<<setw(manip3)<<help->res<<endl;
  87.         help=help->next;
  88.     }
  89.     return 0;
  90. }
  91.  
  92. /**
  93. 10
  94. Orlov B.S. IEM 59
  95. Bryanskii D.D. IMI 59.2
  96. Orlov E.S. IMI 60
  97. Babudorzhiev E.D. IMI 57
  98. Munkoev A.A. IMI 29
  99. Orlov O.O. FTF 33
  100. Jahmal J.J. IEM 46
  101. Scherbakov A.U. IMI 48
  102. Baldanov Z.Z. IMI 58
  103. Zammond J.C. FTF 38
  104. Orlov
  105. IMI
  106. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement