Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <string.h>
- #include <fstream>
- #include <algorithm>
- using namespace std;
- struct samochod
- {
- char marka[20];
- int cena;
- char kolor[20];
- };
- void wprowadzenieDanych(int n, samochod t[])
- {
- for (int i = 0; i < n; i++)
- {
- for (int i = 0; i<n; i++)
- {
- cout << "Podaj marke: "; cin >> t[i].marka;
- cout << "Podaj kolor: "; cin >> t[i].kolor;
- cout << "Podaj cene: "; cin >> t[i].cena;
- }
- }
- }
- bool kolor_sorter(samochod const& l, samochod const& r) {
- if (l.kolor != r.kolor)
- return l.kolor < r.kolor;
- else
- return false;
- }
- bool marka_sorter(samochod const& l, samochod const& r) {
- if (l.marka != r.marka)
- return l.marka < r.marka;
- else
- return false;
- }
- void sortuj(samochod t[], int n)
- {
- cout << "Sortowanie po" << endl;
- cout << "[0] - kolorze" << endl;
- cout << "[1] - marce" << endl;
- int w;
- cin >> w;
- switch (w)
- {
- case 0:
- sort(t, t + n, &kolor_sorter);
- break;
- case 1:
- sort(t, t + n, &marka_sorter);
- break;
- default:
- cout << "Zly wybor" << endl;
- }
- }
- void zlicz(samochod t[], int n)
- {
- int * zliczenia;
- zliczenia = new int[n];
- }
- int main()
- {
- samochod *tab;
- int n;
- cout << "Podaj ilosc samochodow..."; cin >> n;
- tab = new samochod[n];
- wprowadzenieDanych(n, tab);
- sortuj(tab, n);
- zlicz(tab, n);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement