计算一个数是否可为两个素数之和C

计算一个数是否可为两个素数之和

#include<stdio.h>

intpalindrome(int n);

intmain()

{

    int i,n;

         scanf("%d",&n);

         for(i=2;i<=n/2;i++)

         {

                   if(palindrome(i)==1)

                   {

                            if(palindrome(n-i)==1)

                            {

                                     printf("yes\n");

                                     break;

                            }

 

                            else

                                     continue;

                   }

        

                   else

                            continue;

                  

 

         }

         if(i==n/2&&n!=5)

                   printf("sorry\n");

        

         return 0;

}

intpalindrome(int n )

{

         int i,flag=1;

         for(i=2;i<=n/2;i++)

         {

                   if(n%i==0)

                   {

                            flag=0;

                            break;

                   }

                   else

                            continue;

         }

         return flag;

}


阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/munan2017/article/details/80316423
个人分类: C语言习题
上一篇八进制与十进制之间的转换C语言
下一篇判断一个数是否为回文数C
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭