Advertisement
Vedrann

Untitled

May 31st, 2021
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char firstWord[30];
  9.     char secondaryWord[30];
  10.    
  11.     cout<<"Molimo upisite prvu rijec.\n";
  12.     scanf("%s", firstWord);
  13.    
  14.     cout<<"Molimo upisite drugu rijec.\n";
  15.     scanf("%s", secondaryWord);
  16.    
  17.     int wordOneSize = strlen(firstWord);
  18.     int wordTwoSize = strlen(secondaryWord);
  19.    
  20.     if (wordOneSize >= wordTwoSize)
  21.     {
  22.         for (int i = wordOneSize; i >= 0; i--)
  23.         {
  24.             cout<<firstWord[i];
  25.         }
  26.        
  27.         cout<<"\n";
  28.     } else {
  29.         for (int i = wordTwoSize; i >= 0; i--)
  30.         {
  31.             cout<<secondaryWord[i];
  32.         }
  33.        
  34.         cout<<"\n";
  35.     }
  36.    
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement