fork download
  1. #include <stdio.h>
  2. #include <locale.h>
  3. #include <math.h>
  4. #include <string.h>
  5.  
  6. int opoc(char *a)
  7.  
  8. {setlocale(LC_CTYPE, "Russian");
  9. int k, s=0, i;
  10. k = strlen(a)-1;
  11. for(i=0; a[i]!='\0'; ++i)
  12. {
  13. if(a[i]=='1')
  14. s = s+pow(2,j);
  15. j--;
  16. }
  17. return s;
  18. }
  19. int main() {
  20. setlocale(LC_CTYPE, "Russian");
  21. char z[1000];
  22. printf("Введите двоичное число:");
  23. gets(z);
  24. printf("%d\n",opoc(z));
  25. return 0;
  26. }
  27.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘opoc’:
prog.c:14:13: error: ‘j’ undeclared (first use in this function)
 s = s+pow(2,j);
             ^
prog.c:14:13: note: each undeclared identifier is reported only once for each function it appears in
prog.c:9:5: warning: variable ‘k’ set but not used [-Wunused-but-set-variable]
 int k, s=0, i;
     ^
prog.c: In function ‘main’:
prog.c:23:1: warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
 gets(z);
 ^~~~
stdout
Standard output is empty