Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #define NMAX 126
- #define SZUI8 (sizeof(uint8_t) * 8)
- void setFlag(uint8_t *x, int pos) {
- (*x) |= (1 << pos);
- }
- int getFlag(uint8_t x, int pos) {
- return 1 & (x >> pos);
- }
- int main(void) {
- int n;
- scanf("%d", &n);
- static uint8_t arr[NMAX];
- for (int x, i = 0; i < n; i++) {
- scanf("%d", &x);
- setFlag(&arr[x / 8], x % SZUI8);
- }
- for (int i = 0; i < NMAX; i++) {
- for (int j = 0; j < SZUI8; j++) {
- if (getFlag(arr[i], j)) {
- printf("%d ", i * 8 + j);
- }
- }
- }
- puts("");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement