Advertisement
TheDuliX_

Untitled

Sep 12th, 2021
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. string rec;
  9. cout << "Unesite rec: ";
  10. cin >> rec;
  11. int duzina = rec.length()-1;
  12. bool status = false;
  13.  
  14. for(int i = 0; i < duzina; i++){
  15. if (rec.at(i) != rec.at(duzina-i)) {
  16. status = true;
  17. break;
  18. }
  19. }
  20. if (status == true){
  21. cout<< "Nije palindrom";
  22. } else {
  23. cout<< "Jeste palindrom";
  24. }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement