[ create a new paste ] login | about

Link: http://codepad.org/Ihe2SUI1    [ raw code | output | fork ]

slevy1ster - C++, pasted on Jul 31:
#include <iostream>
using namespace std;


 int find(char f,string str) {
        static int len = str.length() - 1;
        static int count = 1;
        int temp = 0;

       if (len < 0) {
            cout << count << "\n";
            return -99;
       }
       else
       if ( str[len] == f) {
            return len;
       }

       len--;
       count++;
       temp = find( f, str );
       cout << temp << "\n";
       return temp;
}

int main() {
   char ch = 'z';
   int res = find(ch,"I");
   if (res < 0) {
      cout << "Letter '" << ch << "' was not found";
   }
   return 0;
}


Output:
1
2
3
2
-99
Letter 'z' was not found


Create a new paste based on this one


Comments: