首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
波耶菠萝蜜
2025年7月23日 16:51
字符串翻转 题解:
P1006
回复 0
|
赞 0
|
浏览 166
核心是在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
|
赞 5
|
浏览 684
#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
|
赞 10
|
浏览 919
#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
|
赞 20
|
浏览 955
//思路:倒序输出数组。 #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--) { ...
虚拟的世界
2025年2月16日 19:17
字符串翻转 题解:
P1006
回复 1
|
赞 3
|
浏览 699
这个编译器有问题?
固态氧化碳
2025年2月9日 15:43
字符串翻转 题解:fgets函数会读取换行符 注意字符串长度要多减一个
P1006
回复 0
|
赞 30
|
浏览 1.4k
#include <stdio.h> #include <string.h> int main() { char s[1000]; fgets(s,sizeof(s),stdin); for(int i=strlen(s)-2;i>=0;i--) { printf("%c",s[i]); } }
xidianshangan
2025年1月1日 15:47
字符串翻转 题解:
P1006
回复 0
|
赞 1
|
浏览 715
print(input()[::-1])
ccccccyes
2024年8月21日 19:33
字符串翻转 题解:
P1006
回复 0
|
赞 15
|
浏览 1.6k
#include <iostream> #include <algorithm> //reverse是algorithm中的 using namespace std; int main(){ string str; //string类详解 cin>>str; reverse(str.begin(),str.end());  ...
18919717626
2024年6月30日 15:21
字符串翻转 题解:getline
P1006
回复 1
|
赞 16
|
浏览 1.4k
#include <iostream> using namespace std; int main(){ string s; getline(cin,s); for(int i = s.size() - 1;i >= 0;i --){ cout << s[i]; } return 0; }
Candour
2024年4月19日 23:51
字符串翻转 题解:
P1006
回复 0
|
赞 8
|
浏览 959
#include<bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); reverse(s.begin(), s.end()); cout << s; return 0; }
1
2
3
4
题目
字符串翻转
题解数量
35
发布题解
在线答疑
热门题解
1
字符串翻转 题解:fgets函数会读取换行符 注意字符串长度要多减一个
2
字符串翻转 题解:
3
字符串翻转 题解:假如你没听说过reverse()
4
字符串翻转 题解:getline
5
字符串翻转 题解:
6
字符串翻转 题解:
7
字符串翻转 题解:C++
8
字符串翻转 题解:string length
9
字符串翻转 题解:C
10
字符串翻转 题解: