1 条题解

  • 0
    @ 2021-6-15 10:11:12

    C :

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    	int a,b,c,d,i,x,j;
    	for(i=3;i<=100;i++)
    	{
    		if(i%2!=0)continue;
    		if(i==4)
    		{
    			printf("%d=",i);
    				printf("%d+",2);
    					printf("%d\n",2);
    					continue;
    		}
    		if(i%2==0)
    		{
    			printf("%d=",i);
    			for(a=2;a<=(i/2);a++)
    			{
    				for(c=2;c<=sqrt(a);c++)
    				if(a%c==0)break;
    				if(a%c==0)continue;
    				if(c>sqrt(a))
    				{
    				for(b=(i/2);b<i;b++)
    				{
    					for(d=2;d<=sqrt(b);d++)
    					if(b%d==0)break;
    				    if(b%d==0)continue;
    				if(d>sqrt(b)&&a+b==i)
    				{
    					printf("%d+",a);
    					printf("%d\n",b);
    					
    				}
    				if(d>sqrt(b)&&a+b==i)break;
    				}
    				}
    			if(d>sqrt(b)&&a+b==i)break;
    			}
    		}
    	}
      return 0;
    }
    

    C++ :

    #include<iostream>
    #include<cmath>
    using namespace std;
    int main()
    {
      int a,x;
      for (a=4;a<=100;a=a+2)
      {for (int b=2;b<=a;++b)
      { int s=2;
    	  while ((s<=floor(sqrt(b)))&&(b%s!=0))
    		s++;
    	  if (s>floor(sqrt(b))) 
    		x=b;
    		int c;
    		c=a-x;
           int l=2;
    	  while ((l<=floor(sqrt(c)))&&(c%l!=0))
    		l++;
    	  if (l>floor(sqrt(c))) {
             cout<<a<<"="<<x<<"+"<<c<<endl;break;}
    	 }}
      return 0;
    }
    

    Pascal :

    var
      i,p,q,j:longint;
      fp,fq:boolean;
      begin
        for i:=4 to 100 do
          if i mod 2=0 then
          begin
          p:=1;
          repeat
          p:=p+1;
          q:=i-p;
          fp:=true;
          for j:=2 to trunc(sqrt(p)) do
            if p mod j=0 then fp:=false;
            fq:=true;
          for j:=2 to trunc(sqrt(q)) do
            if q mod j=0 then fq:=false;
            until fp and fq;
            writeln(i,'=',p,'+',q);
          end;
      end.
    
    • 1

    信息

    ID
    406
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者