Kentoo

V#1

Jan 14th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <locale>
  4.  
  5. using namespace std;
  6.  
  7. void main()
  8. {
  9.     setlocale(LC_ALL, "Russian");
  10.     string surnames = "Коновалова Стрельцов Герасимова Горячева Ковалевская Фролов ";
  11.     char s1[2];
  12.     int count(0);
  13.     cout << "Список женских фамилий: " << endl;
  14.     while (surnames.length() > 0) {
  15.         surnames.copy(s1, 2, surnames.find(' ') - 2);
  16.         if (s1[1] == 'а') {
  17.             count++;   
  18.             cout << surnames.substr(0, surnames.find(' ')) << endl;
  19.         }
  20.         if (s1[0] == 'а' && s1[1] == 'я') {
  21.             count++;
  22.             cout << surnames.substr(0, surnames.find(' ')) << endl;
  23.         }
  24.         surnames.erase(0, surnames.find(' ') + 1);
  25.     }
  26.     if (count == 0)
  27.         cout << "Не найдено женских фамилий" << endl;
  28.     system("pause");
  29. }
Add Comment
Please, Sign In to add comment