STANAANDREY

ghiceste cuv

Nov 27th, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdio.h>
  4. #include <cstdlib>
  5. #include <ctype.h>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     char c[100];
  11.     cin >> c;
  12.     unsigned n = strlen(c);
  13.     int ok = 0;
  14.     cout << "prima litera: " << c[0] << endl << "ultima litera: " << c[n - 1] << endl;
  15.     do
  16.     {
  17.         char c2[100];
  18.         cin >> c2;
  19.         cout << c[0];
  20.         for (int i = 1; i < n - 1; i++)
  21.             if (c[i] == c2[i])
  22.                 cout << c[i];
  23.             else
  24.                 cout << '*';
  25.         cout << c[n - 1];
  26.         cout << endl;
  27.         if (!strcmp(c, c2))
  28.             ok = 1;
  29.     }
  30.     while (!ok);
  31.     puts("Ai ghicit!");
  32.     return 0;
  33. }
Add Comment
Please, Sign In to add comment