解题思路:
相同的字符串进行逆转,用两个不同的变量i,j标记,i记录串尾位置,j记录串头位置,用个for循环就好
参考代码:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1,s2;
cin>>s1;
s2=s1;
for(int i=s1.length()-1,j=0;i>0,j<s1.length();i--,j++)
{
s2[j]=s1[i];
}
cout<<s2;
}
新人第一次写题解,若有什么不正确请多指出,
0.0分
0 人评分
C语言训练-计算1977!* (C语言代码)浏览:899 |
C语言训练-谁家孩子跑最慢* (C语言代码)浏览:1508 |
C二级辅导-进制转换 (C语言代码)浏览:514 |
时间转换 (Java代码)浏览:575 |
字符串问题 (C语言代码)浏览:1521 |
C语言训练-排序问题<1> (C语言代码)浏览:601 |
WU-蓝桥杯算法提高VIP-勾股数 (C++代码)浏览:1607 |
DNA (C语言代码)浏览:395 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:690 |
C二级辅导-分段函数 (C语言代码)浏览:601 |