三个程序在VS2017(Windows10 64位)上调试通过。
第一题:
//文件名:primeNumber.c
//作者:Dragon-Slayer
//修改时间:2019.4.17
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int isPrime(int inputNumber);
//该函数判断inputNumber是否为质数,
//如果是,返回1;如果不是,返回0。
int main()
{
int inputNumber;
int ans;
do
{
printf("Please enter a number: ");
scanf("%d", &inputNumber);
//1既不是素数也不是合数
if (inputNumber == 1)
printf("1 is neither a prime number nor a composite number.\n");
else if (isPrime(inputNumber))
printf("%d is a prime number.\n", inputNumber);
else
printf("%d is a composite number.\n", inputNumber);
printf("0 for quit,any other number for continue: ");
scanf("%d", &ans);
printf("