Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#6 |
初级会员
注册日期: 2008-02-20
年龄: 35
帖子: 12
声望力: 18 ![]() |
![]()
判断从6到上限x的大偶数是否成立:
clear;clc; x=input('x=') n=0; t=x./2-2; if mod(x,2)>0|x<6 disp('data error!') return end for m=2*(3:x./2) for i=2:m./2 k=zhs(i); k1=k; k=zhs(m-i); k2=k; if k1>=1&k2>=1; n=n+1; fprintf('%.0f %.0f=%.0f+%.0f\n',n,m,i,m-i) break end end end if n>=t&n<=t; disp('the numbers which have been examed are all correct!') elseif n>t|n<t; disp('it is wrong!') end |
![]() |
![]() |