Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. // SYSTEM CZWÓRKOWY
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. short int n;
  8.  
  9. cout << "Podaj liczbe do zamiany na system czworkowy: ";
  10. cin >> n;
  11.  
  12. for ( unsigned short int i = 0xc000, p=14 ; i > 0; i >>= 2 , p -= 2 )
  13. {
  14. cout << ((n&i) >> p); // n&i - iloczyn bitowy
  15. }
  16.  
  17. cout << endl;
  18. system("pause");
  19. }
  20.  
  21.  
  22.  
  23. /*
  24. //SYSTEM SZESNASTKOWY
  25. #include <iostream>
  26. using namespace std;
  27.  
  28. int main()
  29. {
  30. short int n;
  31.  
  32. cout << "Podaj liczbe do zamiany na system szesnastkowy: ";
  33. cin >> n;
  34.  
  35. for ( short int i = 0x8000; i>0 ; i >>=1 )
  36. {
  37. cout << (n&i ? '1':'0'); // n&i - iloczyn bitowy
  38. }
  39.  
  40. cout << "#16: " << hex << n;
  41.  
  42. cout << endl;
  43. system("pause");
  44. }
  45. */
  46.  
  47.  
  48.  
  49. /*
  50. //ZADANIE 1
  51. #include <iostream>
  52. using namespace std;
  53.  
  54. int main()
  55. {
  56. int n, suma = 0;
  57.  
  58. cout << "Podaj liczbe: ";
  59. cin >> n;
  60.  
  61. for( n ; n>0 ; )
  62. {
  63. suma = suma + n%10;
  64. n = n/10;
  65. }
  66.  
  67. cout << endl << suma;
  68.  
  69. system("pause");
  70. }
  71. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement