【题目描述】
输入一串以‘!’结束的字符,按逆序输出。
【输入】
如题述。
【输出】
如题述。
【输入样例】
abc!
【输出样例】
cba
这题有一种为了出题而出题的感觉
#include<iostream>
#include<cmath>
using namespace std;
void f(string s,string::size_type n)
{
if(s[n]=='!')
return;
else
{
f(s,n+1);
cout<<s[n];
}
}
int main()
{
string s;
cin>>s;
f(s,0);
}