Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #include<iostream>
- using namespace std;
- template <class t3,class t2>
- t2 porownanie (t3 a , t2 b)
- {
- if (a >= b)
- {
- return a;
- }
- else {
- return b;
- }
- }
- int main()
- {
- int a, b;
- cin >> a>> b;
- cout << porownanie(a, b);
- system("pause");
- }
- */
- /*
- #include<iostream>
- #include<ctime>
- using namespace std;
- template <class typ1, class typ2>
- typ1* bombel(typ1* a, typ2 b)
- {
- for (int i = 0; i < b; i++) {
- for (int j = 1; j < b-i; j++)
- {
- if (a[j - 1] > a[j]) {
- swap(a[j - 1], a[j]);
- }
- }
- }
- return a;
- }
- int main()
- {
- srand(time(NULL));
- int n;
- cin >> n;
- cout << endl;
- int *tab = new int[n];
- for (int i = 0; i < n; i++)
- {
- tab[i] = rand() % 10;
- cout << tab[i] << endl;
- }
- cout << "-----------------------------------" << endl;
- bombel(tab, n);
- for (int i = 0; i < n; i++)
- {
- cout << tab[i] << endl;
- }
- system("pause");
- }
- */
- #include<iostream>
- #include<string>
- using namespace std;
- struct osoba {
- int wiek;
- string imie;
- string nazwisko;
- };
- template <class typ1, class typ2>
- typ1* bombel(typ1* a, typ2 b)
- {
- for (int i = 0; i < b; i++) {
- for (int j = 1; j < b - i; j++)
- {
- if (a[j - 1].wiek > a[j].wiek) {
- swap(a[j - 1], a[j]);
- }
- }
- }
- return a;
- }
- int main()
- {
- int a;
- cout << "Wprowadz liczbe osob: ";
- cin >> a;
- cout << endl;
- osoba *tab = new osoba[a];
- for (int i = 0; i < a; i++)
- {
- cout << "Imie: ";
- cin >> tab[i].imie;
- cout << "Nazwisko: ";
- cin >> tab[i].nazwisko;
- cout << "Wiek: ";
- cin >> tab[i].wiek;
- }
- cout << endl << endl;
- for (int i = 0; i < a; i++)
- {
- cout << "Imie: ";
- cout<< tab[i].imie;
- cout << endl << "Nazwisko: ";
- cout<< tab[i].nazwisko;
- cout << endl << "Wiek: ";
- cout<< tab[i].wiek;
- cout << endl << endl;
- }
- system("pause");
- bombel(tab, a);
- cout << endl << endl;
- for (int i = 0; i < a; i++)
- {
- cout << "Imie: ";
- cout << tab[i].imie;
- cout << endl << "Nazwisko: ";
- cout << tab[i].nazwisko;
- cout << endl << "Wiek: ";
- cout << tab[i].wiek;
- cout << endl << endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement