fork(1) download
  1. #include <stdio.h>
  2.  
  3. int digits(long n);
  4.  
  5. int solve(const long n) {
  6.  
  7. long count[5], max=0;
  8. count[0]=n/2+0.5;
  9.  
  10. /* for(count[1]=1;count[1]<=count[0];count[1]++){
  11.  
  12.   if((digits(count[1])+digits(n-count[1]))>max)
  13.   max=(digits(count[1])+digits(n-count[1]));
  14.  
  15.   }*/
  16. count[1]=n;
  17. count[2]=0;
  18. while(count[1]>9){
  19. count[1]/=10;
  20. count[2]++;
  21. }
  22. count[3]=pow(10,count[2]);
  23. max=digits(count[3]-1)+digits(n-count[3]+1);
  24.  
  25. printf("n = %ld, max = %ld\n", n, max);
  26. return (int)max;
  27.  
  28. }
  29. int digits(long n){
  30. long digit=0;
  31. while(n>9){
  32. digit+=n%10;
  33. n/=10;
  34. }
  35. return digit+n;
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘solve’:
prog.c:22:12: warning: implicit declaration of function ‘pow’ [-Wimplicit-function-declaration]
   count[3]=pow(10,count[2]);
            ^~~
prog.c:22:12: warning: incompatible implicit declaration of built-in function ‘pow’
prog.c:22:12: note: include ‘<math.h>’ or provide a declaration of ‘pow’
prog.c:2:1:
+#include <math.h>
 
prog.c:22:12:
   count[3]=pow(10,count[2]);
            ^~~
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty