Kosty_Fomin

Untitled

Jan 26th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. Calculator.m
  2.  
  3. #import "Calculator.h"
  4. #import "ptViewController.h"
  5. #import "ptViewController.m"
  6.  
  7. @implementation Calculator : NSObject
  8.  
  9.  
  10. - (IBAction)toN{
  11.  
  12.  
  13. const long double a = 2;
  14.  
  15.  
  16. for(int i = 0 ;; i++)
  17. {
  18. if(pow(a, i) >= number)
  19. {
  20. n = i;
  21.  
  22. break;
  23. }
  24. }
  25.  
  26. char mas[n];
  27. int i = 0;
  28.  
  29. while(number != 0)
  30. {
  31. if(number % 2 == 0)
  32. {
  33. mas[i] = '0';
  34. }
  35. else
  36. {
  37. mas[i] = '1';
  38. }
  39. number /= 2;
  40. i++;
  41. }
  42.  
  43. /* for(int i = n; i >= 0; i--)
  44. {
  45. std::cout << mas[i];
  46. }*/
  47.  
  48. }
  49.  
  50. @end
Advertisement
Add Comment
Please, Sign In to add comment