题目:
C语言
#include<stdio.h>
#include<string.h>
void fun_2024_6_20()
{
char str[10001]={0};
gets(str); //不能使用scanf("%d",str)函数,含空格字符串会被视为多组输入。
int len=strlen(str);
len--;
while(len>=0)
{
printf("%c",str[len]);
len--;
}
}
int main(){
fun_2024_6_20();
return 0;
}
C++
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
void fun_2024_6_20()
{
string str;
while(getline(cin,str))
{
reverse(str.begin(),str.end());
cout<<str;
}
}
int main() {
fun_2024_6_20();
return 0;
}
Python
def fun_2024_6_20():
while True:
try:
s=input()
print(s[::-1])
except:
break
fun_2024_6_20()
标签:字符,20,len,2024,算法,str,fun,include,逆序
From: https://blog.csdn.net/weixin_65816128/article/details/139817567