bogdanNiculeasa

Problema vocale/consoane sablon

Dec 7th, 2022
993
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | Software | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5. int isVowel(char ch);
  6. int isConsonant(char ch);
  7.  
  8.  
  9. int main() {
  10.     char s1[51], s2[51];
  11.     cout << "Enter first string: ";
  12.     cin >> s1;
  13.     cout << "Enter second string: ";
  14.     cin >> s2;
  15.  
  16.     for (int i = 0; i < strlen(s1); i++) {
  17.         if (isVowel(s1[i]) && isVowel(s2[i])) {
  18.             cout << "*";
  19.         }
  20.         else if (isConsonant(s1[i]) && isConsonant(s2[i])) {
  21.             cout << "#";
  22.         }
  23.         else {
  24.             cout << "?";
  25.         }
  26.     }
  27.  
  28.     return 0;
  29. }
  30.  
  31. int isVowel(char ch) {
  32.     return strchr("aeiou", ch) != NULL;
  33. }
  34.  
  35. int isConsonant(char ch) {
  36.     if (!isVowel(ch) && (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z')) {
  37.         return 1;
  38.     }
  39.     else {
  40.         return 0;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment