Advertisement
Bidca

El arreglo es palindromo (sin apuntadores).

May 10th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main () {
  4.  
  5.     int tam;
  6.     std::cin >> tam;
  7.  
  8.     int arr [tam];
  9.  
  10.     for (int i = 0; i < tam ; ++i){
  11.         std::cin >> arr [i];
  12.     }
  13.  
  14.     int act = 0, cont = 0;
  15.     while (act < tam / 2){
  16.        if (arr[act] == arr[(tam - 1) - act]){
  17.             ++cont;
  18.         } else {
  19.             break;
  20.         }
  21.         ++act;
  22.     }
  23.  
  24.    std::cout << (cont == tam / 2 ? "Palindromo" : "No es palindromo\n");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement