Guest User

Untitled

a guest
May 7th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #include "Rus.h"
  4. #include <string.h>
  5.  
  6. struct first
  7. {
  8.     char city[15];
  9.     char name[10];
  10. };
  11. int main(void)
  12. {
  13.     int i,b,d=0;
  14.     struct first  *f;
  15.    
  16.     cout<<Rus("Введите колличество рейсов\n");
  17.     cin>>b;
  18.     f = new struct first[b+1];
  19.     cout<<Rus("введите город и модель самолета:\n");
  20.    
  21.     for (i=0; i<b-1; i++)
  22.         cin>>f[i].city>>f[i].name;
  23.     cout<<endl;
  24.     do
  25.     {
  26.     for (i=0; i<b-2; i++)
  27.     {
  28.         if(strcmp(f[i].city, f[i+1].city)>0)
  29.         {
  30.             strcpy(f[b+1].city,f[i].city);
  31.             strcpy(f[i].city,f[i+1].city);
  32.             strcpy(f[i+1].city,f[b+1].city);
  33.         }
  34.        
  35.     }
  36.     d++;
  37.     }
  38.    
  39.     while(d<b*b);
  40.     for (i=0; i<b-1; i++)
  41.         cout<<f[i].city<<" "<<f[i].name<<endl;
  42.    
  43.     delete f;
  44.    
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment