Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib>
- #include<iomanip>
- #include<ctime>
- #include<fstream>
- #include<cmath>
- #include<algorithm>
- #include<vector>
- #include<conio.h>
- using namespace std;
- int i;
- string line;
- int number;
- /*deklaracja struktury kartoteka*/
- struct osoba
- {
- int miejsce;
- string imie;
- string nazwisko;
- int dzien;
- int miesiac;
- int rok;
- string miasto;
- };
- osoba dane[500];
- /*Funkcja - wczytanie danych z istniej1cego pliku baza.txt */
- void Sortowanie_nazwiska()
- {
- system("cls");
- cout<<"Nazwiska w porzadku alfabetycznym: ";
- cout<<endl;
- int size = 0;
- size=i; // i nie ma wartości xD
- cin.ignore(); //important // yyy na pewno ważne ?
- //out string *Array = new string[size]; //Array of pointers
- /*out for (int i = 0; i < size; i++)
- {
- Array[i]=dane[i].nazwisko;
- }*/
- size = 500;
- osoba Array[size]; //tworzymy kopię tablicy / /można zrobić dynamiczną ale nie chce mi się xd
- Array = dane;
- int j = 0;
- bool swap_ = true;
- string temp;
- while (swap_)
- {
- swap_ = false;
- j++;
- for (int l = 0; l < size - j; l++)
- {
- if (Array[l].nazwisko > Array[l + 1].nazwisko)
- {
- /* temp = Array[l];
- Array[l] = Array[l + 1];
- Array[l + 1] = temp;*/ // to można zastąpić po prostu funkcją swap xd
- swap(Array[l],Array[l+1])
- swap_ = true;
- }
- }
- }
- // co to poniżej powinno robić? wypisywać ?
- /*
- for (int k = 0; k < size; k++)
- {
- for (int j = 0; j < i; j++)
- {
- if (Array[k]==dane[j].nazwisko)
- {
- cout<<endl;
- cout <<"Miejsce nr "<<j+1<<endl;
- cout <<"Imie: "<<dane[j].imie<<endl;
- cout <<"Nazwisko: "<<dane[j].nazwisko<<endl;
- cout <<"Miasto: "<<dane[j].miasto<<endl;
- cout <<"Data urodzenia: "<<dane[j].dzien<<"."<<dane[j].miesiac<<"."<<dane[j].rok<<endl;
- }
- }
- }
- cout << endl << endl;
- delete[] Array;
- */
- for (int k = 0; k<size; k++){
- cout <<"imie: " <<Array[k].imie ;
- cout << "nazwisko: "<<Array[k].nazwisko;
- ///...i tak dalej
- }
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement