判断质数

#include<stdio.h>
#include<stdlib.h>
int main ()
{
    int a,x;
    int i=0;
    scanf("%d",&a);
    for(x=2;x<a;x++)
    {
        if(a%x==0)
        {
            
            i++;
            printf("%d\n",x);// 打印所有约数  
            
        }
    }
    if(i==0)
        printf("质数");
    else
        printf("合数");
    return 0;
}

posted @ 2019-07-21 21:22  Cathycat  阅读(108)  评论(0编辑  收藏  举报