Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- #define NMAX 20
- #define WORD_LEN 10
- #define VOWELS "aeiou"
- int n, k, auxK;
- char s[NMAX][WORD_LEN], ans[NMAX][WORD_LEN];
- void read() {
- cin >> n >> k;
- for (int i = 0; i < n; i++) {
- cin >> s[i];
- }
- }
- void solve() {
- for (int i = 0; i < n && auxK < k; i++) {
- int len = strlen(s[i]);
- if (strchr(VOWELS, s[i][len - 1])) {
- strcpy(ans[auxK++], s[i]);
- }
- }
- }
- void write() {
- if (auxK != k) {
- cout << "nu exista" << endl;
- } else {
- for (int i = 0; i < auxK; i++) {
- cout << ans[i] << endl;
- }
- }
- }
- int main() {
- read();
- solve();
- write();
- return 0;
- }
Add Comment
Please, Sign In to add comment