B2028 反向输出一个三位数
一开始自己码的
#include<string>
#include<iostream>
using namespace std;
int main()
{
int x;
string s;
cin >> x;
for (; x != 0; s += to_string(x % 10), x /= 10);
cout << s << endl;
return 0;
}
最后一个测试案例不过,修改无果后借鉴题解:
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int x;
string s;
cin >> x;
s = to_string(x);
reverse(s.begin(), s.end());
cout << s << endl;
return 0;
}
最后一个测试案例仍然无法通过[笑哭]
改成这样才给过:
#include<iostream>
using namespace std;
int main()
{
char a, b, c;
cin >> a >> b >> c;
cout << c << b << a << endl;
return 0;
}
前面是哪里不对吗[发问]
最后再吐槽一句,为什么测试失败的样例不给看啊[笑哭]