查看单个帖子
旧 2008-11-30, 23:17   #3
zhyanchao
初级会员
 
注册日期: 2008-11-30
年龄: 24
帖子: 27
声望力: 17
zhyanchao 正向着好的方向发展
默认 回复: [求助]进来帮我看下这几个题目

第一题:
A='123';
while 1
B=input('please input the keyword:','s');
[m,n]=size(B);
if m==1&n==3
if all(A==B)
break;
end
end
sprintf('the keyword is wrong')
end
运行结果:
please input the keyword:12

ans =

the keyword is wrong

please input the keyword:123
第二题:
>> s=0;
a=[12 13 14;15 16 17;18 19 20;21 22 23];
for k=a
for j=1:4
if rem(k(j),2)==0
s=s+k(j);
end
end
end
s

s =

102
zhyanchao 当前离线   回复时引用此帖