Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- struct element
- {
- string f;
- string io;
- string obsh;
- double res;
- element *next;
- };
- int main(){
- element *beg, *help,*last;
- int manip1=1, manip2=1, manip3=1,manip4=1;
- int n;
- cin>>n;
- beg=new element;
- last=beg;
- for(int i=0; i<n; i++){
- help=new element;
- cin>>help->f>>help->io>>help->obsh>>help->res;
- if(help->f.size()>manip1){
- manip1=help->f.size();
- }
- if(help->io.size()>manip2){
- manip2=help->io.size();
- }
- if(help->obsh.size()>manip4){
- manip4=help->obsh.size();
- }
- int cp=help->res;
- int c=0;
- while(cp){
- cp/=10;
- c++;
- }
- if(c>manip3)
- manip3=c;
- last->next=help;
- last=help;
- }
- last->next=0;
- ///Punkt a
- string usl;
- cin>>usl;
- int mx=1e9;
- element *ans;
- help=beg->next;
- while(help){
- if(help->f==usl && mx>help->res){
- ans=help;
- mx=help->res;
- }
- help=help->next;
- }
- cout<<endl<<"a)"<<endl;
- cout<<ans->f<<' '<<ans->io<<' '<<ans->obsh<<' '<<ans->res<<endl<<endl<<"b)"<<endl;
- help=beg->next;
- while(help){
- element *help2=help->next;
- while(help2){
- if(help2 && help->f > help2->f){
- string s1=help->f,s2=help->io,s3=help->obsh;
- double s4=help->res;
- help->f=help2->f;
- help->io=help2->io;
- help->res=help2->res;
- help->obsh=help2->obsh;
- help2->f=s1;
- help2->io=s2;
- help2->res=s4;
- help2->obsh=s3;
- }
- help2=help2->next;
- }
- help=help->next;
- }
- cin>>usl;
- // cout<<manip1<<' '<<manip2<<' '<<manip3<<endl;
- help=beg->next;
- while(help){
- if(help->obsh==usl)
- cout<<setw(manip1)<<help->f<<' '<<setw(manip2)<<help->io<<' '<<setw(manip4)<<help->obsh<<' '<<setw(manip3)<<help->res<<endl;
- help=help->next;
- }
- return 0;
- }
- /**
- 10
- Orlov B.S. IEM 59
- Bryanskii D.D. IMI 59.2
- Orlov E.S. IMI 60
- Babudorzhiev E.D. IMI 57
- Munkoev A.A. IMI 29
- Orlov O.O. FTF 33
- Jahmal J.J. IEM 46
- Scherbakov A.U. IMI 48
- Baldanov Z.Z. IMI 58
- Zammond J.C. FTF 38
- Orlov
- IMI
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement