Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- #include<vector>
- using namespace std;
- vector<int> banda;
- void afisareBanda() {
- cout << "Banda:" << endl;
- vector<int>::iterator it;
- for (it = banda.begin(); it != banda.end(); it++) {
- cout << *it << endl;
- }
- }
- int main()
- {
- cout << "Test";
- int numar;
- cout << "Introdu numarul in binar:" << endl;
- cin >> numar;
- int stareaInitiala = 0;
- int stareaCurenta = stareaInitiala;
- bool stareaFinala = false;
- int s = 0;
- int c = 0;
- while (numar>0)
- {
- c = numar % 10;
- s++;
- banda.push_back(c);
- numar = numar / 10;
- }
- cout << "Numarul cifrelor: " << s << endl;
- afisareBanda();
- int ok = 1;
- int start = 0;
- int end = s - 1;
- vector<int>::iterator it;
- while (stareaFinala != true) {
- if (banda.at(start) == banda.at(end) && !banda.empty()) {
- banda.erase(banda.begin());
- banda.erase(banda.end()-1);
- start++;
- end--;
- }
- else {
- stareaFinala = true;
- ok = 0;
- }
- }
- if (ok == 1) {
- cout << "Numarul este palindrom!" << endl;
- }
- else {
- cout << "Numarul nu ete palidrom!" << endl;
- }
- //while (stareaFinala != true) {
- //}
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement