#6124: 程式正確但還是寫錯誤 (WA (line:2) 輸出短少)


meisgod (123)


#include <stdio.h>
#include <math.h>

int main()
{
    int x,y,i,j=0;
    scanf("%d",&x);
    y=(int)sqrt(x);
    if(x>= 2 && x<=2147483647)
    {
        for(i=2;i<y;i++)
        {
            if(x%i==0)
            {
                j++;
                break;
            }
        }
    }
    if(j>0)
    {
        printf("非質數");
    }
    else
    {
        printf("質數");
    }
    return 0;
}
 
 
 WA (line:2)
輸出短少
您共輸出 1 行。
請問這是什麼意思?? 想很久但是一直想不出來 還請多多幫忙 謝謝
 
#6126: Re:程式正確但還是寫錯誤 (WA (line:2) 輸出短少)


sponge (qd)


#include
#include

int main()
{
    int x,y,i,j=0;
    scanf("%d",&x);
    y=(int)sqrt(x);
    if(x>= 2 && x<=2147483647)
    {
        for(i=2;i
        {
            if(x%i==0)
            {
                j++;
                break;
            }
        }
    }
    if(j>0)
    {
        printf("非質數");
    }
    else
    {
        printf("質數");
    }
    return 0;
}
 
 
 WA (line:2)
輸出短少
您共輸出 1 行。
請問這是什麼意思?? 想很久但是一直想不出來 還請多多幫忙 謝謝
 

 
把 a001 先搞定吧
 
答案在那。