fork download
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <cmath>
  4. #define max 30
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int tab[21];
  10. int maximum=0;
  11. bool ok=false;
  12. for(int i=0;i<21;i++)tab[i]=0;
  13. int k=10,l,j;
  14. while(true)
  15. {
  16. cin>>l;
  17. tab[l+10]++;
  18. }
  19. for(int i=0;i<21;i++)
  20. if(tab[i]>maximum)maximum=tab[i];
  21.  
  22. for(int i=0;i<21;i++)
  23. {
  24. int dl=round(max*tab[i]/maximum);
  25.  
  26. cout.right;
  27. cout.width(4);
  28. cout<<i-10<<":|";
  29. for(j=0;j<dl;j++)
  30. cout<<"*";
  31. cout.width(max-j+1);
  32. cout<<"|"<<endl;
  33. }
  34. //system("pause");
  35. return 0;
  36. }
  37.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2
3
4
5
6
7
8
9
10
1
compilation info
prog.c:1:19: error: cstdlib: No such file or directory
prog.c:2:20: error: iostream: No such file or directory
prog.c:3:17: error: cmath: No such file or directory
prog.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘namespace’
prog.c: In function ‘main’:
prog.c:11: error: ‘bool’ undeclared (first use in this function)
prog.c:11: error: (Each undeclared identifier is reported only once
prog.c:11: error: for each function it appears in.)
prog.c:11: error: expected ‘;’ before ‘ok’
prog.c:12: error: ‘for’ loop initial declaration used outside C99 mode
prog.c:14: error: ‘true’ undeclared (first use in this function)
prog.c:16: error: ‘cin’ undeclared (first use in this function)
prog.c:19: error: redefinition of ‘i’
prog.c:12: error: previous definition of ‘i’ was here
prog.c:19: error: ‘for’ loop initial declaration used outside C99 mode
prog.c:22: error: redefinition of ‘i’
prog.c:19: error: previous definition of ‘i’ was here
prog.c:22: error: ‘for’ loop initial declaration used outside C99 mode
prog.c:24: warning: implicit declaration of function ‘round’
prog.c:24: warning: incompatible implicit declaration of built-in function ‘round’
prog.c:26: error: ‘cout’ undeclared (first use in this function)
prog.c:32: error: ‘endl’ undeclared (first use in this function)
prog.c:13: warning: unused variable ‘k’
stdout
Standard output is empty