Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main(int argc, char **argv) {
- vector<int> niz;
- int broj, copy, razlika;
- cout << "Unesi broj: ";
- cin >> broj;
- copy=broj;
- while(copy) {
- int i=0;
- niz.insert(niz.begin()+i,copy%10);
- copy/=10;
- i++;
- }
- int mp=1;
- copy=niz[0];
- for (int i=1; i<niz.size(); i++) {
- mp*=10;
- copy+=mp*niz[i];
- }
- razlika=broj-copy;
- if (razlika==0) {
- cout << "ne\n";
- return 0;
- }
- if (razlika<0) razlika=-razlika;
- cout << "razlika: " << razlika << endl;
- vector<int> razvect;
- while (razlika) {
- razvect.push_back(razlika%10);
- razlika/=10;
- }
- int flag=1;
- while (copy) {
- for (int i=0; i<razvect.size(); i++) {
- cout << copy%10 << " i " << razvect[i] << endl;
- int check=0;
- if (razvect[i]==(copy%10)) check=1;
- if (check==0) {
- cout << "ne\n";
- return 0;
- }
- }
- copy/=10;
- }
- cout << "da\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement