Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- struct carOwner {
- string FIO;
- string carModel;
- int carNumber;
- string carColor;
- };
- int main() {
- setlocale(LC_ALL, "rus");
- cout << "Введите количество владельцев" << endl;
- int n;
- cin >> n;
- cout << "Вводите информацию о людях в след. порядке (Фамилия_И.О, Марка_машины, номер, цвет):" << endl;
- carOwner info[n];
- for (int i = 0; i < n; i++) {
- cin >> info[i].FIO >> info[i].carModel >> info[i].carNumber >> info[i].carColor;
- }
- cout << "Выберите действие: " << endl;
- cout << "a) Определить самую распространенную марку автомобиля" << endl << "b) Упорядочить все сведения о владельцах белых машин в алфавитном порядке фамилий владельцев" << endl;
- char choice;
- bool flag = true;
- while (flag) {
- cin >> choice;
- if (choice != 'a' && choice != 'b') {
- cout << "Неверная буква :(" << endl << "попробуйте еще раз" << endl;
- } else {
- flag = false;
- }
- }
- if (choice == 'a') //условие а
- {
- int mx = 0, cntOfMax = 0, prevMx = -2;
- string mostFamous;
- for (int i = 0; i < n; i++) {
- for (int j = i + 1; j < n; j++) {
- if (info[i].carModel == info[j].carModel) {
- mx++;
- }
- }
- if (mx > prevMx) {
- prevMx = mx;
- cntOfMax = 1;
- mx = 0;
- }
- if (mx == prevMx) {
- cntOfMax++;
- mx = 0;
- }
- }
- int cnt = 0;
- cout << prevMx << " " << cntOfMax;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement