Advertisement
Guest User

kebab stare baby prądem

a guest
Oct 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. nineth();
  5. return 0;
  6. }
  7.  
  8. void first() {
  9. int a, b, c;
  10. printf("podaj liczb� a\n");
  11. scanf("%d", &a);
  12.  
  13. printf("podaj liczb� b\n");
  14. scanf("%d", &b);
  15.  
  16. printf("podaj liczb� c\n");
  17. scanf("%d", &c);
  18.  
  19. int max;
  20. //rozwi�zanie pierwsze
  21. max = a;
  22. if(b > max) {
  23. max = b;
  24. }
  25. if(c > max) {
  26. max = c;
  27. }
  28.  
  29. //rozwi�zanie drugie
  30. max = a;
  31. (b>max)?(max=b):max;
  32. (c>max)?(max=c):max;
  33.  
  34. //wynik
  35. printf("najwi�ksza liczba to %d", max);
  36. }
  37.  
  38. void second() {
  39. char a, b, c;
  40. printf("podaj liczb� a\n");
  41. scanf("%c", &a);
  42.  
  43. printf("podaj liczb� b\n");
  44. scanf(" %c", &b);
  45.  
  46. printf("podaj liczb� c\n");
  47. scanf(" %c", &c);
  48.  
  49. char max;
  50. //rozwi�zanie pierwsze
  51. max = a;
  52. if(b > max) {
  53. max = b;
  54. }
  55. if(c > max) {
  56. max = c;
  57. }
  58.  
  59. //rozwi�zanie drugie
  60. max = a;
  61. (b>max)?(max=b):max;
  62. (c>max)?(max=c):max;
  63.  
  64. //wynik
  65. printf("najp�niej wyst�puje litera %c", max);
  66. }
  67.  
  68. void third() {
  69. unsigned char a, b;
  70. printf("podaj liczb� a\n");
  71. scanf("%u", &a);
  72.  
  73. printf("podaj liczb� b\n");
  74. scanf("%u", &b);
  75.  
  76. unsigned char and = a&b;
  77. unsigned char or = a|b;
  78. unsigned char xor = a^b;
  79. printf("a AND b = dec: %u oct: %o hex: %x \n", and, and, and);
  80. printf("a OR b = dec: %u oct: %o hex: %x \n", or, or, or);
  81. printf("a XOR b = dec: %u oct: %o hex: %x \n", xor, xor, xor);
  82. }
  83.  
  84. void fourth() {
  85. int a;
  86. short int b;
  87. double c;
  88. printf("int: %d , short int: %d , double: %lf", a, b, c);
  89. }
  90.  
  91. void fifth() {
  92. int a, b;
  93. printf("podaj liczb� a\n");
  94. scanf("%d", &a);
  95.  
  96. printf("podaj liczb� b\n");
  97. scanf("%d", &b);
  98.  
  99. printf("wynik dzielenia: %d", a/b);
  100. }
  101.  
  102. void sixth() {
  103. int a, b;
  104. printf("podaj liczb� a\n");
  105. scanf("%d", &a);
  106.  
  107. printf("podaj liczb� b\n");
  108. scanf("%d", &b);
  109.  
  110. if(a%b==0) {
  111. printf("%d", a);
  112. } else {
  113. printf("%d", b);
  114. }
  115. }
  116.  
  117. void seventh() {
  118. int a;
  119. printf("podaj liczb�\n");
  120. scanf("%d", &a);
  121. printf("%d", a&1==0);
  122. if((a&1)==0) {
  123. printf("liczba ta jest parzysta");
  124. } else {
  125. printf("liczba ta jest nieparzysta");
  126. }
  127. }
  128. void eighth() {
  129. unsigned char a;
  130. printf("%u \n", a);
  131. a -= 1;
  132. printf("%u", a);
  133. //unsigned char jest 8 bitowy, bez bitu znaku, wi�c odj�cie 1 od 0 daj�ce liczb� ujemn� jest interpretowane jako liczba dodatnia 8 bitowa: 255
  134. }
  135.  
  136. void ninth() {
  137. unsigned int a, b;
  138. printf("podaj liczb� a\n");
  139. scanf("%u", &a);
  140.  
  141. printf("podaj liczb� b\n");
  142. scanf("%u", &b);
  143.  
  144. unsigned int and = ~(~a|~b);
  145. printf("iloczyn bitowy a AND b: %u \n", and);
  146.  
  147. unsigned int or = ~(~a&~b);
  148. printf("suma bitowa a OR b: %u", or);
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement