Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<iomanip>
  4. #include<ctime>
  5. #include<fstream>
  6. #include<cmath>
  7. #include<algorithm>
  8. #include<vector>
  9. #include<conio.h>
  10. using namespace std;
  11. int i;
  12. string line;
  13. int number;
  14.  
  15. /*deklaracja struktury kartoteka*/
  16. struct osoba
  17. {
  18.     int miejsce;
  19.     string imie;
  20.     string nazwisko;
  21.     int dzien;
  22.     int miesiac;
  23.     int rok;
  24.     string miasto;
  25. };
  26. osoba dane[500];
  27.  
  28. /*Funkcja - wczytanie danych z istniej1cego pliku baza.txt */
  29. void Sortowanie_nazwiska()
  30. {
  31.     system("cls");
  32.     cout<<"Nazwiska w porzadku alfabetycznym: ";
  33.     cout<<endl;
  34.     int size = 0;
  35.     size=i; // i  nie ma wartości xD
  36.     cin.ignore(); //important // yyy na pewno ważne ?
  37.  //out   string *Array = new string[size]; //Array of pointers
  38.    
  39.   /*out  for (int i = 0; i < size; i++)
  40.     {
  41.         Array[i]=dane[i].nazwisko;
  42.     }*/
  43.     size = 500;
  44.     osoba Array[size]; //tworzymy kopię tablicy / /można zrobić dynamiczną ale nie chce mi się xd
  45.     Array = dane;
  46.     int j = 0;
  47.     bool swap_ = true;
  48.     string temp;
  49.     while (swap_)
  50.     {
  51.         swap_ = false;
  52.         j++;
  53.         for (int l = 0; l < size - j; l++)
  54.         {
  55.             if (Array[l].nazwisko > Array[l + 1].nazwisko)
  56.             {
  57.               /*  temp = Array[l];
  58.                 Array[l] = Array[l + 1];
  59.                 Array[l + 1] = temp;*/  // to można zastąpić po prostu funkcją swap xd
  60.                 swap(Array[l],Array[l+1])
  61.                 swap_ = true;
  62.             }
  63.         }
  64.     }
  65.  
  66.     // co to poniżej powinno robić? wypisywać  ?
  67.     /*
  68.     for (int k = 0; k < size; k++)
  69.     {
  70.         for (int j = 0; j < i; j++)
  71.         {
  72.             if (Array[k]==dane[j].nazwisko)
  73.             {
  74.                 cout<<endl;
  75.                 cout <<"Miejsce nr "<<j+1<<endl;
  76.                 cout <<"Imie: "<<dane[j].imie<<endl;
  77.                 cout <<"Nazwisko: "<<dane[j].nazwisko<<endl;
  78.                 cout <<"Miasto: "<<dane[j].miasto<<endl;
  79.                 cout <<"Data urodzenia: "<<dane[j].dzien<<"."<<dane[j].miesiac<<"."<<dane[j].rok<<endl;
  80.  
  81.             }
  82.         }
  83.     }
  84.     cout << endl << endl;
  85.  
  86.     delete[] Array;
  87. */
  88. for (int k = 0; k<size; k++){
  89.     cout <<"imie: " <<Array[k].imie ;
  90.     cout << "nazwisko: "<<Array[k].nazwisko;
  91. ///...i tak dalej
  92. }
  93.     system("PAUSE");
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement