日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

1.7 编程基础之字符串 27 单词翻转 4分 python

發布時間:2025/3/15 python 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1.7 编程基础之字符串 27 单词翻转 4分 python 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
""" 1.7 編程基礎之字符串 27 單詞翻轉 4分 http://noi.openjudge.cn/ch0107/24/ https://blog.csdn.net/hy_696/article/details/106412888 https://blog.csdn.net/m0_43456002/article/details/102729230LeetCode--最后一個單詞的長度(python版) https://www.jianshu.com/p/e45152efc507python反轉list的三種方法 https://blog.csdn.net/qq_37969201/article/details/80406726""" a=input().split() a=list(a) lena=len(a) i=0 while i<lena-1:#print(str(list(reversed(a[i])))+",",end=' ')print( str(a[i][: :-1]),end=' ')i+=1print( str(a[lena-1][: :-1]))

C++代碼:

/* 1.7編程基礎之字符串_27單詞翻轉04 http://noi.openjudge.cn/ch0107/27/ */ #include<iostream> #include<cstring> #include<string> using namespace std;string a;void Reverse(int lft,int r) {char x;for(int i=lft,j=r;i<j;i++,j--){x=a[i];a[i]=a[j];a[j]=x;} }int main() {int n,i;getline(cin,a);int lena=0;for(i=0;i<a.length();i++){if(a[i]==' '){Reverse(lena,i-1);lena=i+1; }if(i==a.length()-1){Reverse(lena,i);lena=i+1;}}cout<<a<<endl;return 0; }

總結

以上是生活随笔為你收集整理的1.7 编程基础之字符串 27 单词翻转 4分 python的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。