Re: [問題] 邏輯判斷問題已回收
※ 引述《sylviachines (菇)》之銘言:
: 題目要我算出一個1*3的矩陣
: 每個值都是隨機的 且介於0~9
: 當矩陣中出現兩個以上7的時候
: 跑出"lucky"的字串
: 否則就是unlucky
: 簡單來說就是類似那種會出現3個7的拉霸
: 這是我寫的程式
: x =fix(rand(1,3)*9)
index = find( x == 7 );
if ( ~isempty(index) )
if ( length(index) >= 2 )
disp('Lucky');
else
disp('unlucky');
end
else
disp('Unlucky');
end
: if find(x==7) ans=[1&&3];
: disp('Lucky');
: elseif find(x==7) ans=[2&&3];
: disp('Lucky');
: elseif find(x==7) ans=[1&&2];
: disp('Lucky');
: elseif find(x==7) ans=[1&&2&&3];
: disp('Lucky');
: else
: disp('Unlucky');
: end
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.167.57.202
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章