Advertisement
Guest User

Ist not done

a guest
Dec 13th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. ifstream cin("bac.txt");
  8. int n,k,put=2;
  9. int cont_par,aux,ok;
  10. cin>>n;
  11. while(cin>>k){
  12. cont_par=1;
  13. aux=k;
  14. if(k%2==0){
  15. while(k%2==0 || k==1){
  16. ok=0;
  17. if(k/2==1){
  18. for(int i=cont_par;i>1;i--){
  19. k*=2;
  20. }
  21. cout<<k<<" ";
  22. break;
  23. }else{
  24. ok=1;
  25. cont_par++;
  26. k/=2;
  27. }
  28. }
  29. }
  30. else{
  31. while(k%2!=0){
  32. if(put>=k){
  33. cout<<put<<" ";
  34. break;
  35. }else{
  36. put*=2;
  37.  
  38. }
  39. }
  40. }
  41. cont_par=1;
  42. while(aux%2==0){
  43. if(aux%2!=0){
  44. for(int i=cont_par;i>=1;i--){
  45. put*=2; }
  46. if(put>=aux){
  47. cout<<put<<" ";
  48. break;
  49. }
  50. }else{
  51. cont_par++;
  52. aux/=2;
  53. }
  54. }
  55. }
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement