回复: [求助]进来帮我看下这几个题目
第一题:
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
|