请问C语言中多余的空行是怎么回事呀?是编译器的问题吗?

有一个C语言的编程练习,是输入正整数,然后显示所有小于该数的质数。
我写出来是这样的

#include <stdio.h>

int check_prime(long unsigned checking_num);

int main(void)
{
    long unsigned entered_num;
    long unsigned checking_num;
    int count = 0;

    printf("Enter an integer, this program will show you all the prime number less than the number you entered.\n");
    while (scanf("%lu", &entered_num) == 1)
    {
        printf("There are the following prime number less than the number you entered:\n");
        for (checking_num = 2,count = 0; checking_num < entered_num; checking_num++)
        {



            if (check_prime(checking_num) == 1)
            {

                printf("%lu\t", checking_num);
                count++;
            }
            if (count % 5 == 0)
                printf("\n");
        }
        printf("\n");

        if (count == 0)
            printf("There is no prime number less than the number you entered in.\n");
        printf("\nEnter another number to continue, Q to quit.\n");
    }

    return 0;

}

int check_prime(long unsigned checking_num)
{
    long unsigned div;
    int isprime;

    for (div = 2, isprime = 1; div*div <= checking_num; div++)
    {
        if ( checking_num % div == 0)
            isprime = 0;
    }

    return isprime;
}

其中有一个每输出5个质数就输出一个换行,但是不知道为什么总会多出来很多空行,截图如下图片说明
请大佬帮忙解决一下...

查看全部
Steve_Ive
Steve_Ive
2019/04/03 19:43
  • c语言
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

3个回复