Advertisement
Guest User

Anton, You'd Better Not Copy This.

a guest
Nov 25th, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main()
  6. { bool CarryOn = true;
  7. string ContOrNo;
  8. while(CarryOn == true)
  9. {
  10. cout << "Please input a decimal number without symbols or spaces" << endl;
  11. int DecimalNumber = 0;
  12. cin >> DecimalNumber;
  13. vector<int> BinaryResultVector;
  14. while (DecimalNumber > 0)
  15. {
  16. BinaryResultVector.push_back(DecimalNumber % 2);
  17. if(DecimalNumber % 2 == 1)
  18. {
  19. DecimalNumber = DecimalNumber--;
  20.  
  21. }
  22. DecimalNumber = DecimalNumber / 2;
  23.  
  24. }
  25. for(int i = BinaryResultVector.size()-1; i >= 0; i--)
  26. {
  27. cout << BinaryResultVector[i];
  28. }
  29. cout << "." << endl;
  30. cout << "do you want to continue? Key in any key if so, n if not" << endl;
  31. cin >> ContOrNo;
  32. if(ContOrNo == "n" || ContOrNo == "no")
  33. {
  34. CarryOn = false;
  35. }
  36.  
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement