Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <conio.h>
- #include <clocale>
- using namespace std;
- struct client {
- string surname;
- string country;
- int year;
- int price;
- };
- void show_sorted_by_year( client clients [], int n ) {
- int changes = 1;
- client temp_client;
- while ( changes != 0 ) {
- for ( int i = 0; i < n; i++ ) {
- changes = 0;
- for ( int j = i + 1; j < n; j++ ) {
- if ( clients[i].year < clients[j].year ) {
- temp_client = clients[i];
- clients[i] = clients[j];
- clients[j] = temp_client;
- changes++;
- }
- }
- }
- }
- cout << "Отсортированный массив клиентов по убыванию года турпоездки: " << endl;
- for ( int i = 0; i < n; i++ ) {
- cout << "Фамилия: " << clients[i].surname << "; Страна: " << clients[i].country << "; Год: " << clients[i].year << "; Стоимость: " << clients[i].price << endl;
- }
- }
- void show_by_price( client clients [], int n, int X) {
- cout << "Клиенты, стоимость тура которых не превышает " << X << " гривен. " << endl;
- for ( int i = 0; i < n; i++ ) {
- if ( clients[i].price <= X ) {
- cout << "Фамилия: " << clients[i].surname << "; Страна: " << clients[i].country << "; Год: " << clients[i].year << "; Стоимость: " << clients[i].price << endl;
- }
- }
- }
- int main( )
- {
- setlocale( LC_ALL, "Russian" );
- const int n = 4;
- client arr[n] = {
- "dsadasdsa", "r", 1990, 290292,
- "dsadas", "dsa", 15483, 20222,
- "asdsa", "asdas", 200, 309340,
- "asdsad", "asdsao", 333333, 200000
- };
- show_sorted_by_year( arr, n );
- cout << endl << endl;
- show_by_price( arr, n, 150000 );
- _getch( );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement