fork download
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. cher A;
  6. int N, Q[100], i, c=0, s=0, r=0, T;
  7. scanf("%d", &N);
  8.  
  9. for (i=0; i<N; i++)
  10. {
  11. scanf("%d %s", &Q[i], &A);
  12. T+=Q[i];
  13.  
  14. if (A == "C")
  15. {
  16. c+=Q[i];
  17.  
  18. }
  19. else if (A == "S")
  20. {
  21. s+=Q[i];
  22.  
  23. }
  24. else if (A == "R")
  25. {
  26. r+=Q[i];
  27.  
  28. }
  29.  
  30. }
  31. printf("Total: %d cobaias\n", T);
  32. printf("Total de coelhos: %d\n", c);
  33. printf("Total de ratos: %d\n", r);
  34. printf("Total de sapos: %d\n", s);
  35. printf("Percentual de coelhos: %.2lf %\n", c*100/T);
  36. printf("Percentual de ratos: %.2lf %\n", r*100/T);
  37. printf("Percentual de sapos: %.2lf %\n", s*100/T);
  38. return 0;
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:5:5: error: unknown type name 'cher'
     cher A;
     ^
prog.c:11:15: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'int *' [-Wformat=]
         scanf("%d %s", &Q[i], &A);
               ^
prog.c:14:15: warning: comparison between pointer and integer
         if (A == "C")
               ^
prog.c:14:15: warning: comparison with string literal results in unspecified behavior [-Waddress]
prog.c:19:20: warning: comparison between pointer and integer
         else if (A == "S")
                    ^
prog.c:19:20: warning: comparison with string literal results in unspecified behavior [-Waddress]
prog.c:24:20: warning: comparison between pointer and integer
         else if (A == "R")
                    ^
prog.c:24:20: warning: comparison with string literal results in unspecified behavior [-Waddress]
prog.c:35:12: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
     printf("Percentual de coelhos: %.2lf %\n", c*100/T);
            ^
prog.c:35:12: warning: unknown conversion type character 0xa in format [-Wformat=]
prog.c:36:12: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
     printf("Percentual de ratos: %.2lf %\n", r*100/T);
            ^
prog.c:36:12: warning: unknown conversion type character 0xa in format [-Wformat=]
prog.c:37:12: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
     printf("Percentual de sapos: %.2lf %\n", s*100/T);
            ^
prog.c:37:12: warning: unknown conversion type character 0xa in format [-Wformat=]
stdout
Standard output is empty