STANAANDREY

bac2k21 sb3 2

Mar 29th, 2022 (edited)
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. #define NMAX 20
  5. #define WORD_LEN 10
  6. #define VOWELS "aeiou"
  7. int n, k, auxK;
  8. char s[NMAX][WORD_LEN], ans[NMAX][WORD_LEN];
  9.  
  10. void read() {
  11.     cin >> n >> k;
  12.     for (int i = 0; i < n; i++) {
  13.         cin >> s[i];
  14.     }
  15. }
  16.  
  17. void solve() {
  18.     for (int i = 0; i < n && auxK < k; i++) {
  19.         int len = strlen(s[i]);
  20.         if (strchr(VOWELS, s[i][len - 1])) {
  21.             strcpy(ans[auxK++], s[i]);
  22.         }
  23.     }
  24. }
  25.  
  26. void write() {
  27.     if (auxK != k) {
  28.         cout << "nu exista" << endl;
  29.     } else {
  30.         for (int i = 0; i < auxK; i++) {
  31.             cout << ans[i] << endl;
  32.         }
  33.     }
  34. }
  35.  
  36. int main() {
  37.     read();
  38.     solve();
  39.     write();
  40.     return 0;
  41. }
  42.  
Add Comment
Please, Sign In to add comment