Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. #include <iostream>
  2. //#include <iomanip>
  3. //#include <cmath>
  4. using namespace std;
  5.  
  6. // int(32 biti cu semn) : [-2^31,2^31)
  7. // long long(64 biti cu semn) : [-2^63,2^63)
  8. // unsigned int(32 biti fara semn) : [0,2^32)
  9. // unsigned long long(64 ..) : [0,2^64)
  10.  
  11. // char : [0,255]
  12.  
  13. char a = 'a';
  14. char b = 97;
  15.  
  16. // float - precizie de 6 zecimale
  17. // double - precizie de 12 zecimale
  18. // bool - True/False , 0/1
  19.  
  20. void operators()
  21. {
  22. cout<<int(a)<<b<<'\n';
  23. //cout<<fixed<<setprecision(6)<<sqrt(2)<<'\n';
  24.  
  25. bool x = 1, y = 0;
  26. cout<<(x && y)<<'\n';
  27. cout<<(x || y)<<'\n';
  28. cout<<(x + y)<<'\n'; // + , - , / , *
  29. cout<<(x & y)<<'\n'; // 1101(2) & 101(2) = 101(2)
  30. cout<<(x | y)<<'\n'; // 1101(2) & 110(2) = 1111(2)
  31. cout<<(x ^ y)<<'\n'; // 1101(2) & 110(2) = 1101(2)
  32. // 1 ^ 1 = 0
  33. // 1 ^ 0 = 1
  34. // 0 ^ 1 = 1
  35. // 0 ^ 0 = 0
  36. cout<<(256>>2)<<'\n';
  37. cout<<(1<<8)<<'\n';
  38. }
  39.  
  40. int sqr(int x)
  41. {
  42. return x*x;
  43. }
  44.  
  45. int fact(int x)
  46. {
  47. int rez = 1;
  48. for (int i=1;i<=x;++i)
  49. rez *= i;
  50. return rez;
  51. }
  52.  
  53. int fact2(int x)// fact2(5) -> fact2(4) -> .. -> fact2(1) -> fact2(2) -> .. -> fact2(5)
  54. {
  55. if ( x <= 1 )
  56. return 1;
  57. else
  58. return x * fact2(x-1);
  59. }
  60.  
  61. int a2(int);
  62. int a3(int);
  63.  
  64. int a2(int x)
  65. {
  66. if ( x > 0 )
  67. return (x+1)*a3(x-1);
  68. return 1;
  69. }
  70.  
  71. int a3(int x)
  72. {
  73. if ( x > 0 )
  74. return x*a2(x-1);
  75. return 1;
  76. }
  77.  
  78. int main()
  79. {
  80. // if , while , for
  81. for (int i=1;i<=20;++i)
  82. {
  83. if ( i == 5 ) continue; // sare peste un pas in cel mai din interior for
  84. cout<<i<<' ';
  85. }
  86. cout<<'\n';
  87. for (int i=1;i<=20;++i)
  88. {
  89. if ( i == 5 ) break; // opreste cel mai din interior for
  90. cout<<i<<' ';
  91. }
  92. cout<<'\n';
  93.  
  94. #define sqr(x) (x*x)
  95. cout<<sqr(5)<<'\n';
  96. #undef sqr
  97.  
  98. //cout<<sqr(5)<<'\n';
  99.  
  100. //#if
  101. //#elif // elseif
  102. //#else
  103. //#endif
  104.  
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement