Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int const num = 8;
- struct NOTE {
- string NAME;
- string TELE;
- int BDAY[3];
- };
- void input_num_show_info(NOTE info[]) {
- string tel;
- cout << "Введите TELE: ";
- cin >> tel;
- for (int i = 0; i < num; i++) {
- if (info[i].TELE == tel) {
- cout << "Найден: " << info[i].NAME;
- for (int j = 0; j < 3; j++) {
- cout << " " << info[i].BDAY[j];
- }
- cout << endl;
- }
- }
- }
- int main() {
- NOTE BLOCKNOTE[num];
- for (int i = 0; i < num; i++) {
- cout << "BLOCKNOTE[" << i << "]" << endl;
- cout << "Введите NAME: ";
- cin >> BLOCKNOTE[i].NAME;
- cout << "Введите TELE: ";
- cin >> BLOCKNOTE[i].TELE;
- for (int j = 0; j < 3; j++) {
- cout << "Введите BDAY[" << j << "]: ";
- cin >> BLOCKNOTE[i].BDAY[j];
- }
- cout << endl;
- }
- for (int i = 0; i < num; i++) {
- for (int j = 0; j < num - i - 1; j++) {
- int sum_left = BLOCKNOTE[j].BDAY[0] + BLOCKNOTE[j].BDAY[1] * 30 + BLOCKNOTE[j].BDAY[2] * 365;
- int sum_right = BLOCKNOTE[j + 1].BDAY[0] + BLOCKNOTE[j + 1].BDAY[1] * 30 + BLOCKNOTE[j + 1].BDAY[2] * 365;
- if (sum_left > sum_right) {
- string str_buffer;
- int int_buffer;
- str_buffer = BLOCKNOTE[j].NAME;
- BLOCKNOTE[j].NAME = BLOCKNOTE[j + 1].NAME;
- BLOCKNOTE[j + 1].NAME = str_buffer;
- str_buffer = BLOCKNOTE[j].TELE;
- BLOCKNOTE[j].TELE = BLOCKNOTE[j + 1].TELE;
- BLOCKNOTE[j + 1].TELE = str_buffer;
- for (int k = 0; k < 3; k++) {
- int_buffer = BLOCKNOTE[j].BDAY[k];
- BLOCKNOTE[j].BDAY[k] = BLOCKNOTE[j + 1].BDAY[k];
- BLOCKNOTE[j + 1].BDAY[k] = int_buffer;
- }
- }
- }
- }
- input_num_show_info(BLOCKNOTE);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement