mkd123 @ 2024-07-29 08:05:51
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string b;
getline(cin, b);
reverse(b.begin(), b.end());
cout <<b;
return 0;
}
by HFZ20111110 @ 2024-07-29 08:10:50
@mkd123 万一带前导0你也敢输出?
by HFZ20111110 @ 2024-07-29 08:11:31
@mkd123 sorry,好像没有前导0
by HFZ20111110 @ 2024-07-29 08:13:06
@mkd123 我要不要告诉你,其实可以这样做
#include<bits/stdc++.h>
using namespace std;
char a,b,c,d;
int main(){
scanf("%c%c%c.%c",&a,&b,&c,&d);
printf("%c.%c%c%c",d,c,b,a);
return 0;
}
by tianenyang @ 2024-07-29 11:34:18
直接用string之后循环减减输出不好吗 strings;cin>>s;for(int i=s.size()-1;i>=0;i--)输出
by tianenyang @ 2024-07-29 11:36:02
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
for(int i=s.size()-1;i>=0;i--) cout<<s[i];
return 0;
}
这样试试
by mkd123 @ 2024-07-29 20:14:15
@HFZ20111110 嗷嗷,感谢
by mkd123 @ 2024-07-29 20:15:17
@tianenyang ok,感谢
by tianenyang @ 2024-07-30 07:39:36
@mkd123 ok
by gongxiaokaoyan @ 2024-08-27 16:32:11
啊?我也是这么写的,就输入不同
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
cin >> s;
reverse(s.begin(), s.end());
cout << s;
return 0;
}