Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main (int argc, char ** argv) {
- if (argc != 2 )
- {
- printf("Blad, wprowadzono nieprawidlowe argumenty \n");
- return 1;
- }
- int n = atoi(argv[1]);
- for (int i = 0; i < n; i ++){
- char* slowo = malloc(sizeof (*slowo));
- *slowo = '\0';
- for (int j = i; j>0; j = j/2) {
- if (j%2==0)
- {strcat (slowo, "0");}
- else
- {strcat (slowo, "1"); }
- }
- int l = strlen(slowo);
- for(l; l>0; l--)
- printf("%c", slowo[l]);
- printf("0\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement