5-4

#include<stdio.h>

#include<math.h>

int main(void)

{

         int count,m;

         int prime(int m);

 

         count=0;

         for(m=2;m<=100;m++){

                   if(prime(m)!=0){

                            printf("%6d",m);

                            count++;

                            if(count%10==0) printf("\n");

                   }

         }

         printf("\n");

}

int prime(int m)

{

         int i,n;

 

         if(m==1)return 0;

         n=sqrt(m);

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

                   if(m%i==0){

                            return 0;

                   }

                   return 1;

}

posted @ 2013-10-04 18:46  zhaoyang16  阅读(135)  评论(0编辑  收藏  举报