Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <fstream>
- using namespace std;
- void sign(int, ofstream&);
- void reverseString(const string&, ofstream&);
- int main()
- {
- int s;
- string k;
- ofstream outfile("c:\\USERS\\STUDENT\\Desktop\\outfile.txt");
- cout << "Enter an integer" << endl;
- cin >> s;
- sign(s, outfile);
- outfile<< endl;
- cout << "Enter a string" << endl;
- cin >> k;
- reverseString(k, outfile);
- return 0;
- }
- void sign(int n, ofstream &outfile)
- {
- if (n==0)
- {
- return;
- }
- else
- {
- outfile << "No Parking" << endl;
- sign(--n, outfile);
- return;
- }
- }
- void reverseString(const string& str, ofstream &outfile)
- {
- int n = str.size();
- if(n == 1)
- {
- outfile << str << endl;
- return;
- }
- else
- {
- outfile << str[n-1];
- string temp = str.substr(0, --n);
- reverseString(temp, outfile);
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement