Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Julia Konefał 331805 lista 4
- #include <stdio.h>
- #include <stdlib.h>
- void bin(unsigned int x)
- {
- unsigned int a = 1 << 31;
- while(a>=1)
- {
- if (x >= a)
- {
- x -= a;
- printf("1");
- }
- else printf("0");
- a /= 2;
- }
- printf(" ");
- }
- void wypisz(const char* str, unsigned int c)
- {
- printf("%s", str);
- bin(c);
- printf("%u", c);
- printf("\n");
- }
- int main()
- {
- unsigned int a,b,c;
- scanf("%u %u", &a, &b);
- c = a;
- wypisz(" a:", c);
- c= ~a;
- wypisz(" not a:", c);
- c = b;
- wypisz(" b:", c);
- c= ~b;
- wypisz(" not b:", c);
- c= a&b;
- wypisz(" a and b:", c);
- c= a|b;
- wypisz(" a or b:", c);
- c= a^b;
- wypisz(" a xor b:", c);
- c= a<<b;
- wypisz("a shift b:", c);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement