Подредени по височина

Да се напише програма, която позволява да се въведе (чрез структура) имената и височината на двама души, и после ги отпечатва, подредени по височина.

Публикувано в 12а с етикети . Постоянна връзка.

9 коментара по Подредени по височина

  1. Luccar каза:
     #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    struct visochina
    { char ime[10];
    float visochina;};
    int main(int argc, char *argv[])
    { 
    
    visochina a,b;
    
    cout<<"Wuwedete imenata i visochinite do tqh"<<endl;
    cin>>a.ime>>a.visochina;
    cout<<"Wuwedete vtoriq tuch"<<endl;
    cin>>b.ime>>b.visochina;
    
    if (a.visochina>b.visochina){
    cout<<"ime: "<<a.ime<<" Visochina: " <<a.visochina<<endl;
    cout<<"ime: "<<b.ime<<" Visochina: " <<b.visochina<<endl;}
    else {
    cout<<"ime: "<<b.ime<<" Visochina: " <<b.visochina<<endl;
    cout<<"ime: "<<a.ime<<" Visochina: " <<a.visochina<<endl;}
    
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    
  2. Adrian каза:
     struct chovek
        {
               char ime[60];
               double rust;
               } ;
             chovek x,y;  
              cin>>x.ime>>x.rust;
              cin>>y.ime>>y.rust;
              
              {if (x.rust>y.rust)
              cout <<x.ime<<" "<<x.rust<<endl<<y.ime<<" "<<y.rust<<endl;
              else
              cout <<y.ime<<" "<<y.rust<<endl<<x.ime<<" "<<x.rust<<endl;
              }
    
  3. Nadq каза:
     struct uchenik
        {
          double visochina;
          char ime[20];
        };
          uchenik a,b;
          cout<<"Vuvedete imeto na purviq uchenik i negovata visochina:"<<endl;
          cin>>a.ime>>a.visochina;
          cout<<"Vuvedete imeto na vtoriq uchenik i negovata visochina:"<<endl;
          cin>>b.ime>>b.visochina;
          cout<<"podredeni po visochina:"<<endl;
        if (a.visochina<b.visochina)
            cout<<a.ime<< ' '<<a.visochina <<"\n" <<b.ime<< ' '<<b.visochina<<"\n";
        else cout<<b.ime<< ' '<<b.visochina <<"\n" <<a.ime<< ' '<<a.visochina<<"\n";
    
  4. Kosmos каза:
     
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        struct uchenik 
        {
              char ime[30]; 
              double  visochina;
        };
        
        uchenik x, y;
        cout<<"vavedete ime na purviq uchenik : ";
        cin>>x.ime;
        
         cout<<"vavedete visochina na purviq uchenik : ";
        cin>>x.visochina;
        
         cout<<"vavedete ime na vtoriq uchenik : ";
        cin>>y.ime;
        
         cout<<"vavedete visochina na vtoriq uchenik : ";
        cin>>y.visochina;
       
       if ((x.visochina)>(y.visochina))
       {
    cout<<"\n Ime:"<<x.ime; 
    cout<<"\n Visochina:"<<x.visochina <<"\n";
    cout<<"\n Ime:"<<y.ime <<"\n";
    cout<<"\n Visochina:"<<y.visochina <<"\n";
    }
    
       if ((y.visochina)>(x.visochina))
       {
    cout<<"\n Ime:"<<y.ime;
    cout<<"\n Visochina:"<<y.visochina <<"\n";
    cout<<"\n Ime:"<<x.ime; 
    cout<<"\n Visochina:"<<x.visochina <<"\n";
    }
                   
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    
    
  5. vbox7 каза:
     #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    
    int main(int argc, char *argv[])
    { 
      struct chovek
     {
      char ime[10];
      double vis;
     };
     chovek a, b;
    
     cout<<"vuvedete imeto i visochinata na purvia chovek"<<endl;
     cin>> a.ime>> a.vis;
     cout<<"vuvedete imeto i visochinata na vtoria chovek"<<endl; 
     cin>>b.ime>>b.vis;
     if (a.vis>b.vis)
     cout<<a.ime<<" "<<a.vis<<endl<<b.ime<<" "<<b.vis<<endl;
     if (b.vis>a.vis)
     cout<<b.ime<<" "<<b.vis<<endl<<a.ime<<" "<<a.vis<<endl;
     
          system("PAUSE");
        return EXIT_SUCCESS;
    } 
  6. TVD каза:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        struct hora
        {
            char ime[20];
           double visochina;
            
        };
        hora x,y;
        cout<<"Ime na purviq:";
          cin>>x.ime;
        cout<<"Visochinata na purviq:";
          cin >>x.visochina;
        cout<<"Ime na vtoriq:";
          cin>>y.ime;
        cout<<"Visochinata na vtoriq:";
          cin>>y.visochina;
            if (x.visochina > y.visochina)
              cout<<x.ime<<","<<y.ime<<endl;
            else (y.visochina > x.visochina);
              cout<<y.ime<<","<<x.ime<<endl;              
            else cout<<"Ravni sa po visochina!"<<endl;
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    
  7. Данаил каза:

    6 решения – не вярвам на очите си!
    Абсолютен рекорд :-) Дори vbox7 се разписаха…

    Luccar – с чувство за хумор :-)
    Nadq – тоя път Adrian ви би по лаконичност!
    Kosmos – печелите награда за най-прегледна програма!
    TVD – проверили сте всички възможни варианти…

    vbox7 – дейййй, доживях! :-)

Вашият коментар