fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int main()
  5. {
  6. char * input ="1234";
  7. int size = strlen(input);
  8. int prev_val=0,curr_val=0,prev_prev_val=1;
  9. for(int i=0;i<size;i++)
  10. {
  11. if(i!=0)
  12. {
  13. if((int)(input[i-1])<;2+48 || ((int)(input[i-1])==2+48 &&
  14. (int)(input[i])<;7+48))
  15. curr_val = prev_val + prev_prev_val;
  16. else
  17. curr_val = prev_val;
  18. }
  19. else
  20. {
  21. curr_val = 1;
  22. prev_val = 1;
  23. }
  24. prev_prev_val = prev_val;
  25. prev_val = curr_val;
  26. }
  27. cout<<curr_val<<endl;
  28.  
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:6:17: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
   char * input ="1234";
                 ^~~~~~
prog.cpp:13:28: error: expected primary-expression before ‘;’ token
       if((int)(input[i-1])<;2+48 || ((int)(input[i-1])==2+48 &&
                            ^
prog.cpp:13:28: error: expected ‘)’ before ‘;’ token
prog.cpp:14:17: error: expected primary-expression before ‘;’ token
 (int)(input[i])<;7+48))
                 ^
prog.cpp:14:17: error: expected ‘)’ before ‘;’ token
prog.cpp:14:22: error: expected ‘;’ before ‘)’ token
 (int)(input[i])<;7+48))
                      ^
prog.cpp:16:7: error: expected ‘}’ before ‘else’
       else
       ^~~~
prog.cpp:19:5: error: ‘else’ without a previous ‘if’
     else
     ^~~~
prog.cpp: At global scope:
prog.cpp:27:3: error: ‘cout’ does not name a type
   cout<<curr_val<<endl;
   ^~~~
prog.cpp:29:1: error: expected unqualified-id before ‘return’
 return 0;
 ^~~~~~
prog.cpp:30:1: error: expected declaration before ‘}’ token
 }
 ^
stdout
Standard output is empty