首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
xsw
2026年2月3日 17:11
字符串翻转 题解:
P1006
回复 0
|
赞 0
|
浏览 14
#include<iostream> #include<algorithm> using namespace std; int main() { string s; cin >> s; reverse(s.begin(), s.end()); cout << s << endl; return 0; }
mlx
2026年1月28日 22:37
字符串翻转 题解:
P1006
回复 0
|
赞 1
|
浏览 87
#include<iostream> #include<algorithm> using namespace std; string str; int main() { cin>>str; reverse(str.begin(),str.end()); cout<<str; return 0; }
yauqq
2026年1月28日 13:19
字符串翻转 题解:
P1006
回复 0
|
赞 0
|
浏览 66
#include<bits/stdc++.h> using namespace std; int main(){ string str; while(cin >> str){ reverse(str.begin(),str.end()); cout << str << endl; } return 0; }
Jun_
2026年1月23日 13:31
字符串翻转 题解:c++
P1006
回复 0
|
赞 2
|
浏览 97
#include<stdio.h> #include <iostream> #include<math.h> #include <stdlib.h> #include <string> #include<cctype> #include<algorithm> using namespace std; int main () { string str; getline(...
jerryking
2026年1月4日 22:06
字符串翻转 题解:
P1006
回复 0
|
赞 6
|
浏览 337
#include<stdio.h> #include<string.h> int main(){ char str[100]={0}; fgets(str,sizeof(str),stdin); //fgets更安全,避免输入的字符串超过字符数组范围产生错误 str[strcspn(str,"\n")] = '\0';&nbs...
无名1
2025年9月2日 18:38
字符串翻转 题解:C++
P1006
回复 0
|
赞 14
|
浏览 876
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; for(int i=s.length()-1;i>=0;i--){ cout<<s[i]; } return 0; }
波耶菠萝蜜
2025年7月23日 16:51
字符串翻转 题解:
P1006
回复 0
|
赞 2
|
浏览 760
核心是在p[]中的运算,注意越界问题 int a = strlen(p); for (int i = 0; i < a; i++) { // 正确循环次数 printf("%c", p[a - 1 - i]); // 从末尾向前遍历
cc12345
2025年3月20日 18:26
字符串翻转 题解:由于不会reverse,故采用swap交换位置
P1006
回复 0
|
赞 6
|
浏览 1.2k
#include<bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int low=0; int high=s.length()-1; while(low<high) { swap(s[low],s[high]); low++; high--; } cout<<s; }
阿灿
2025年3月15日 03:05
字符串翻转 题解:string length
P1006
回复 0
|
赞 14
|
浏览 1.4k
#include<bits/stdc++.h> using namespace std; int main(){ string a; int n; cin>>a; n = a.length(); while(n--){ cout<<a[n]; } return 0; }
zxjrheaven
2025年3月5日 21:26
字符串翻转 题解:假如你没听说过reverse()
P1006
回复 0
|
赞 22
|
浏览 1.5k
//思路:倒序输出数组。 #include<bits/stdc++.h> using namespace std; int main() { char str[105]; scanf("%s",str); int num=strlen(str); for(int i=num-1;i>=0;i--) { ...
1
2
3
...
5
题目
字符串翻转
题解数量
41
发布题解
在线答疑
热门题解
1
字符串翻转 题解:fgets函数会读取换行符 注意字符串长度要多减一个
2
字符串翻转 题解:
3
字符串翻转 题解:假如你没听说过reverse()
4
字符串翻转 题解:getline
5
字符串翻转 题解:
6
字符串翻转 题解:C++
7
字符串翻转 题解:string length
8
字符串翻转 题解:
9
字符串翻转 题解:C
10
字符串翻转 题解:C++