12345678910111213141516171819202122232425 |
- #include <stdio.h>
- void exchange(int x, int b[], int *size) {
- int i = 0;
- while (x > 0) {
- b[i++] = x % 2;
- x /= 2;
- }
- *size = i;
- }
- int main() {
- int x, size, b[50], i;
- scanf("%d", &x);
- exchange(x, b, &size);
- for (i = size - 1; i >= 0; i--) {
- printf("%d", b[i]);
- }
- return 0;
- }
|