Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <conio.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     wcin.imbue(locale(".866"));
  11.     wcout.imbue(locale(".866"));
  12.  
  13.     int N;
  14.     wcout << L"Введите N="; cin >> N;
  15.     wstring* words = new wstring[N];
  16.     wstring** words_selected_ptrs = new wstring*[N];
  17.     int words_selected_i = 0;
  18.  
  19.     for (int i=0; i < N; i++)
  20.     {
  21.         wcout << L"Слово " << (i + 1) << ": ";
  22.         wcin >> words[i];
  23.  
  24.         int good = 1;
  25.         for (int s = 1; s < words[i].length(); s++)
  26.         {
  27.             if (words[i][s] < words[i][s - 1])
  28.             {
  29.                 good = 0;
  30.                 break;
  31.             }
  32.         }
  33.  
  34.         if (good)
  35.         {
  36.             words_selected_ptrs[words_selected_i] = &(words[i]);
  37.             words_selected_i++;
  38.         }
  39.     }
  40.  
  41.     for (int i = 0; i < words_selected_i; i++)
  42.     {
  43.         wcout << (wstring) *(words_selected_ptrs[i]) << endl;
  44.     }
  45.  
  46.  
  47.     delete[] words;
  48.     delete[] words_selected_ptrs;
  49.  
  50.     getchar();
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement