题解 | #反序输出#
反序输出
https://www.nowcoder.com/practice/171278d170c64d998ab342b3b40171bb
#include <iostream> #include<string> //其实本题直接swap(s[0],s[3]),swap(s[1],s[2])就Ok 了 using namespace std; string reverse(string s) { int length=s.length(); for(int i=0;i<length/2;i++) { char t=s[i]; s[i]=s[length-1-i]; s[length-1-i]=t; } return s; } int main() { string s; while (cin >>s) { // 注意 while 处理多个 case cout << reverse(s)<< endl; } } // 64 位输出请用 printf("%lld") //题目意思理解错误,指的是有n行,每个字符串有4个字符