Advertisement
kanciastopantalones

rasy, nieskonczone

Nov 28th, 2011
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <windows.h>
  4. using namespace std;
  5. struct profesja{
  6.        char nazwa[30];
  7.        float atrybut;
  8.        };
  9.        
  10. void zamiana(int &a, int &b)
  11. {
  12.     int temp=a;
  13.     a=b;
  14.     b=temp;
  15. }
  16.  
  17. void sortowanie(int tab[], int n)
  18. {
  19.  int i,k,j;
  20.  for(i=0;i<n-1;i++)
  21.  {
  22.      k=i;
  23.      for(j=i+1;j<n;j++)
  24.      {
  25.          if(j<n) if(tab[j]<tab[k]) k=j;
  26.      }
  27.      zamiana(tab[i],tab[k]);
  28.  }                
  29. }    
  30.  
  31. int main()
  32. {
  33.     profesja tab[5];
  34.     for (int i=0;i<5;i++)
  35.     {
  36.         cout << "podaj nazwe " << i+1 << " klasy: ";
  37.         cin >> tab[i].nazwa;
  38.         cout << "podaj atrybut " << i+1 << " postaci: ";
  39.         cin >> tab[i].atrybut;
  40.     }
  41.     cout << endl;
  42.     for (int j=0;j<5;j++)
  43.     {
  44.         cout << j+1 << ". RASA: " << tab[j].nazwa << "\t" << " ATRYBUT: " << tab[j].atrybut << endl;
  45.        
  46.     }
  47.     cout << endl;
  48.     int a;
  49.     do
  50.     {
  51.         cout << "ilosc postaci do konfrontacji: ";
  52.         cin >> a;
  53.     }while(a>=5);
  54.    
  55.     int tab2[5];
  56.     for (int k=0;k<a;k++)
  57.     {
  58.         cout << "wybierz numer pozycji postaci do porownania: ";
  59.         cin >> tab2[k];
  60.        
  61.     };
  62.     cout << endl << "WYBRALES: ";
  63.     for(int l=0;l<a;l++)
  64.     {
  65.             cout << tab[tab2[l]-1].nazwa << endl;
  66.     }
  67.    
  68.     for(int m=0;m<a;m++)
  69.     {
  70.             cout
  71.    
  72.    
  73.             cin.ignore();
  74.             getchar();
  75.             return 0;
  76. }
  77.  
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement