前50个素数求法和输出对齐与换行

#include<stdio.h>
int main()
{
    int x=1;
    int cot=0;//素数的个数 
    while(cot<=50){
        int i;
        int count=1;
        for(i=2;i<x;i++){
            if(x%i==0){
                count=0;
                break; 
            }
        }
        if(count==1){
            cot++;
            printf("%d\t",x);//输出数字的对齐 
            if(cot%5==0){
            printf("\n");//输出数字的换行 
        }
        }
        x++;
    }

     return 0;
 } 

猜你喜欢

转载自blog.csdn.net/m0_62780474/article/details/122597801