Advertisement
halexandru11

38, programu stie ce rimeaza, nu ca blaga

Nov 23rd, 2020
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     char a[101], b[101];
  9.     cin >> a;
  10.     cin >> b;
  11.  
  12.     // strlen este unsigned int asa ca il convertesc la int
  13.     // nu ii necesar, da' ii elegant
  14.     int n = (int) strlen(a);
  15.     int m = (int) strlen(b);
  16.  
  17.     // 0 - sufixul nu are nici o vocala
  18.     // 1 - sufixul are cel putin o vocala
  19.     unsigned int ok = 0;
  20.     --n, --m;
  21.     // verific daca ultimele caractere se potrivesc
  22.     // in caz afirmativ le verific pe urmatoarele
  23.     while(n >= 0 && m >= 0 && a[n] == b[m]) {
  24.         if(strchr("aeiouAEIOU", a[n])) {
  25.             ok = 1;
  26.         }
  27.         --n, --m;
  28.     }
  29.  
  30.     // ok = 1
  31.     if(ok) {
  32.         cout << "rimeaza";
  33.     }
  34.     // ok = 0
  35.     else {
  36.         cout << "nu rimeaza";
  37.     }
  38. }
  39.  
Advertisement
RAW Paste Data Copied
Advertisement