MATLAB 循环子字符串
生活随笔
收集整理的這篇文章主要介紹了
MATLAB 循环子字符串
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目描述
輸入一個字符串,取循環子字符串
如abcdef, 給定起始位置及長度,取子字符串, 4,5 ,則輸出defab
輸入
第1行:一個字符串
第2行:整數,表示子字符串的起始位置
第3行:整數,表示子字符串的長度 (長度小于等于原字符串長度)
輸出
一個結果字符串
樣例輸入 Copy
樣例輸出 Copy
cdefgab程序代碼
str = input('','s'); start = input(''); step_size = input('');i = 0; result = ''; redundant = length(str) - start; while truei = i + 1;c = str(start);result = strcat(result, c);start = start + 1;if start > length(str) & redundant > 0start = 1;endif i == step_sizebreak;end end disp(result);總結
以上是生活随笔為你收集整理的MATLAB 循环子字符串的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: QT 调用QWebEngineView显
- 下一篇: C语言 数字翻转输出