fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. int main()
  6. {
  7. char array[5001];
  8. int length,i;
  9. long ans[5000];
  10. array[5000] = '1';
  11. while(1)
  12. {
  13. scanf("%s",&array);
  14. if(array[0]=='0')
  15. {
  16. exit(0);
  17. }
  18. length = strlen(array);
  19. length --;
  20. ans[length] = 1;
  21. length--;
  22. for(i = length; i>=0; i--)
  23. {
  24. if(array[i] == '0')
  25. {
  26. ans[i] = ans[i+1];
  27. ans[i-1] = ans[i];
  28. i -= 1;
  29. }
  30. else if(array[i] > '2')
  31. {
  32. ans[i] = ans[i+1];
  33. }
  34. else if(array[i+2]!='0' && (array[i] == '1' || (array[i]=='2'&&array[i+1]<='6')) )
  35. {
  36. ans[i] = ans[i+1] + ans[i+2];
  37. }
  38. else
  39. {
  40. ans[i] = ans[i+1];
  41. }
  42. }
  43. printf("%ld" ans[i]);
  44. }
  45. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
25114
1111111111
3333333333
0
compilation info
prog.c: In function ‘main’:
prog.c:13: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[5001]’
prog.c:43: error: expected ‘)’ before ‘ans’
prog.c:43: warning: too few arguments for format
prog.c:13: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
stdout
Standard output is empty