Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <array>
- #include <sstream>
- using namespace std;
- struct pila {
- array<int,10> arr;
- int index = 0;
- };
- void push (pila& p, int a)
- {
- p.arr.at(p.index) = a;
- p.index++;
- }
- void pop (pila& p, int& a)
- {
- a = p.arr.at(p.index - 1);
- p.index--;
- }
- int main()
- {
- stringstream input;
- int n, a, b; pila p; bool c = true;
- input << "5 2 1 7 1 2";
- cout << "ingrese cantidad de elementos" << endl;
- input >> n;
- cout << "ingrese los elementos de a uno" << endl;
- for (int i=0; i<n/2; i++)
- {
- input >> a;
- push (p, a);
- }
- if (n%2==1)
- input >> a;
- for (int i=0; i<n/2; i++)
- {
- input >> a;
- pop (p, b);
- if (a != b)
- c = false;
- }
- if (c)
- cout << "es capicua" << endl;
- else
- cout << "no es capicua" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement