fork download
  1. inline int readInt(){
  2. int x=0,c=getchar(),neg=0;
  3. while(c<=32) c=getchar();
  4. if(c=='-') neg=1,c=getchar();
  5. for(;c>='0'&&c<='9';c=getchar()) x=x*10+(c-'0');
  6. return neg?-x:x;
  7. }
  8. inline void writeInt(int x,char endch='\n'){
  9. if(x==0){
  10. putchar('0');
  11. if(endch) putchar(endch);
  12. return;
  13. }
  14. if(x<0){ putchar('-'); x=-x; }
  15. char s[20]; int n=0;
  16. while(x) s[n++]=char('0'+x%10),x/=10;
  17. while(n--) putchar(s[n]);
  18. if(endch) putchar(endch);
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int readInt()’:
prog.cpp:2:15: error: ‘getchar’ was not declared in this scope
     int x=0,c=getchar(),neg=0;
               ^~~~~~~
prog.cpp:2:15: note: ‘getchar’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
+#include <cstdio>
 inline int readInt(){
     int x=0,c=getchar(),neg=0;
               ^~~~~~~
prog.cpp:4:16: error: ‘neg’ was not declared in this scope
     if(c=='-') neg=1,c=getchar();
                ^~~
prog.cpp:6:12: error: ‘neg’ was not declared in this scope
     return neg?-x:x;
            ^~~
prog.cpp: In function ‘void writeInt(int, char)’:
prog.cpp:10:9: error: ‘putchar’ was not declared in this scope
         putchar('0');
         ^~~~~~~
prog.cpp:10:9: note: suggested alternative: ‘char’
         putchar('0');
         ^~~~~~~
         char
prog.cpp:14:14: error: ‘putchar’ was not declared in this scope
     if(x<0){ putchar('-'); x=-x; }
              ^~~~~~~
prog.cpp:14:14: note: suggested alternative: ‘char’
     if(x<0){ putchar('-'); x=-x; }
              ^~~~~~~
              char
prog.cpp:17:16: error: ‘putchar’ was not declared in this scope
     while(n--) putchar(s[n]);
                ^~~~~~~
prog.cpp:17:16: note: suggested alternative: ‘char’
     while(n--) putchar(s[n]);
                ^~~~~~~
                char
prog.cpp:18:15: error: ‘putchar’ was not declared in this scope
     if(endch) putchar(endch);
               ^~~~~~~
prog.cpp:18:15: note: suggested alternative: ‘char’
     if(endch) putchar(endch);
               ^~~~~~~
               char
stdout
Standard output is empty