Advertisement
edutedu

vr 13 pr 4

Dec 4th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. void p(int &n, int c)
  5. {
  6. int d, nr=0, p=1;
  7. while(n)
  8. {
  9. d=n%10;
  10. if(d!=c)
  11. {
  12. nr=nr+(p*d);
  13. p=p*10;
  14. }
  15. n/=10;
  16. }
  17. n=nr;
  18. }
  19. int main()
  20. {
  21. int n, c, a[100], m, i, j ;
  22. cout<<"Introduceti numarul: "; cin>>n;
  23. cout<<"Introduceti cifra: "; cin>>c;
  24. p(n, c);
  25. cout<<n;
  26. cin>>m;
  27. for(i=0; i<m; i++)
  28. cin>>a[i];
  29. for(i=0; i<m; i++)
  30. {
  31. for(j=1; j<=9; j+=2)
  32. p(a[i], j);
  33. if(a[i]!=0)
  34. cout<<a[i]<<" ";
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement