fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5. //문자열로 이진수 입력받기
  6. char input[1000001] = { 0x00, };
  7. gets(input);
  8. int len = strlen(input);
  9. //printf("%d", len);
  10. int num = 0x00;
  11. int input2[350000] = { 0x00, };
  12. int len2 = 0x00;
  13. int j = 0;
  14. int i = len - 1;
  15. //3자리씩 끊어서 배열에 저장
  16. while (1) {
  17. num = input[i] - 48;
  18. input2[j]+=num;
  19. i--;
  20. if (i < 0) break;
  21. num = input[i] - 48;
  22. num *= 2;
  23. input2[j] += num;
  24. i--;
  25. if (i < 0) break;
  26. num = input[i] - 48;
  27. num *= 4;
  28. input2[j] += num;
  29. i--;
  30.  
  31. if (i < 0) break;
  32. j++;
  33. }
  34. //8진수로 출력하기
  35. len2 = strlen(input2);
  36. for (int k = len2 - 1; k >= 0; k--) {
  37. printf("%d", input2[k]);
  38. }
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:7:2: error: ‘gets’ was not declared in this scope
  gets(input);
  ^~~~
prog.cpp:7:2: note: suggested alternative: ‘fgets’
  gets(input);
  ^~~~
  fgets
prog.cpp:35:16: error: cannot convert ‘int*’ to ‘const char*’
  len2 = strlen(input2);
                ^~~~~~
In file included from prog.cpp:2:
/usr/include/string.h:384:35: note:   initializing argument 1 of ‘size_t strlen(const char*)’
 extern size_t strlen (const char *__s)
                       ~~~~~~~~~~~~^~~
stdout
Standard output is empty