首页 > 试题广场 >

数组逆置

[编程题]数组逆置
  • 热度指数:9060 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
输入一个字符串,长度小于等于200,然后将数组逆置输出。

输入描述:
测试数据有多组,每组输入一个字符串。


输出描述:
对于每组输入,请输出逆置后的结果。
示例1

输入

hdssg

输出

gssdh
头像 用户抉择
发表于 2021-03-29 20:22:37
#include <stdio.h> #include <string.h> int main(){     char s[200];     while( 展开全文
头像 牛客575349009号
发表于 2023-03-19 14:03:18
#include <stdio.h> #include <string.h> int main() { char s[200]; while(scanf("%s",&s)!=EOF){ int len=strlen(s); f 展开全文
头像 小徐小徐啊啊
发表于 2024-03-10 21:24:09
#include <stdio.h> #include <string.h> int main() { char a[200]; while(scanf("%s",&a)!=EOF) { //char c=getchar(); f 展开全文
头像 牛客7777779号
发表于 2023-02-23 11:22:05
用c++自带的reverse逆转函数 #include <algorithm> #include <iostream> using namespace std; int main() { string str; while (cin >> str) 展开全文
头像 牛客7777779号
发表于 2023-02-23 11:29:52
不用c++ reverse函数的解法:(常规char数组方法)注意!尾指针指到字符数组最后一位是'\0',并不是有效字符, 此时,尾指针q需要回退一位。 #include <algorithm> #include <iostream> using namespace std 展开全文
头像 MountainsHao
发表于 2024-03-15 17:25:41
#include <stdio.h> #include <string.h> int main() { char s[210]; while (scanf("%s", s) != EOF) { int len=strle 展开全文
头像 也不容易的小白菜很怕黑
发表于 2023-03-24 22:48:57
#include<stdio.h> int main() { char string[100]; scanf("%s", string); int len = strlen(string); for (int i = 0; i < len / 2; 展开全文
头像 牛客127952153号
发表于 2023-01-07 11:40:16
#include <iostream> #include <string> #include <algorithm> using namespace std; int main() { string str; while (cin >> 展开全文
头像 chong_0428
发表于 2024-03-03 22:26:24
while True: try: s = input() print(s[::-1]) except: break
头像 KoukiAlpha
发表于 2023-01-24 15:37:56
#include <iostream> #include <algorithm> using namespace std; int main() { string str; while(cin >> str) { reverse( 展开全文