Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how can a script that reads a number of strings from standard input and prints them in reverse order be written ?

1 回表示 (過去 30 日間)
Roan Raymond
Roan Raymond 2016 年 12 月 21 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
.
  2 件のコメント
Antonio Aguirre
Antonio Aguirre 2016 年 12 月 21 日
Also, if you don't actually want to modify the container holding the strings then the following descending order for-loop:
a = {'dsfd','fsdfsdf','f43r344'}; start = length(a);
for i=1:start disp(a((start+1)-i)) end
James Tursa
James Tursa 2016 年 12 月 21 日
What have you done so far? Please post your code and ask specific questions about it. Then we can offer suggestions and corrections.

回答 (2 件)

Antonio Aguirre
Antonio Aguirre 2016 年 12 月 21 日
Try the function fliplr();
If:
A = {'t','d','f'};
A = fliplr(A)
ans =
1×3 cell array
'f' 'd' 't'

John BG
John BG 2016 年 12 月 22 日
編集済み: John BG 2016 年 12 月 22 日
Neither FOR loops nor flipr needed, just use the right indexing:
str='how can a script that reads a number of strings from standard input and prints them in reverse order be written ?'
str_reverse=str([end:-1:1])
? nettirw eb redro esrever ni meht stnirp dna tupni dradnats morf sgnirts fo rebmun a sdaer taht tpircs a nac woh
if you find my answer useful would you please mark it as Accepted Answer by clicking on the ACCEPT ANSWER button?
thanks in advance for time and attention
John BG

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by