Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //se citesc n nr naturale de maxim 9 cifre fiecare ..afisati folosind metoda divide toate numerele care au suma cifrelor pare mai mare decat suma cifrelor impare ..daca nu exista nr afisam nu exista
- #include <iostream>
- using namespace std;
- int v[100],n;
- int verifica (int x)
- {
- int sp=0,si=0,c;
- while(x)
- {
- c=x%10;
- if(c%2==0)
- sp=sp+c;
- else
- si=si+c;
- x=x/10;
- }
- if(sp>si)
- return 1;
- return 0;
- }
- int div(int v[],int s,int d)
- {int ok=0;
- if(s==d)
- {if(verifica(v[s])==1)
- { cout<<v[s];
- ok=1;
- }}
- else
- div(v,s,(s+d)/2);
- div(v,(s+d)/2+1,d);
- }
- int main()
- {int i,ok;
- cin>>n;
- for(i=1;i<=n;i++)
- cin>>v[i];
- div(v,1,n);
- if(ok==0)
- cout<<"nu exista";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement