家人们看看我这段为啥devc++不能用啊
#include<stdio.h>int isPrime(int x,int knownPrimes[],int numberOfKnownPrimes);
int main(void)
{
const int number = 100;
int prime = {2};
int count = 1;
int i = 3;
while( count < number){
if( isPrime(i, prime, count)){
prime = i;
}
i++;
}
for ( i = 0; i<number;i++ ){
printf("%d",prime);
if( (i+1)%5 ) printf("\t");
else printf("\n");
}
return 0;
}
int isPrime(int x,int knownPrimes[],int numberOfKnownPrimes)
{
int ret = 1;
int i;
for( i = 0;i < numberOfKnownPrimes; i++ ){
if( x % knownPrimes == 0){
ret = 0;
break;
}
}
return ret;
} 那个number老是报错,我不是已经用const int 定义过了吗 用#define number 100试试 #include <stdio.h>
int isPrime(int x,int knownPrimes[],int numberOfKnownPrimes);
int main(void)
{
const int number = 100;
//int prime = {2};
int prime;
for(size_t i = 0; i < number; ++i) prime = 2;
int count = 1;
int i = 3;
while( count < number){
if( isPrime(i, prime, count)){
prime = i;
}
i++;
}
for ( i = 0; i<number;i++ ){
printf("%d",prime);
if( (i+1)%5 ) printf("\t");
else printf("\n");
}
return 0;
}
int isPrime(int x,int knownPrimes[],int numberOfKnownPrimes)
{
int ret = 1;
int i;
for( i = 0;i < numberOfKnownPrimes; i++ ){
if( x % knownPrimes == 0){
ret = 0;
break;
}
}
return ret;
}
人造人 发表于 2021-11-19 12:27
啥意思 人造人 发表于 2021-11-19 12:27
请问我源代码是啥问题,为啥不能编译 上岸吧李哥 发表于 2021-11-19 16:05
请问我源代码是啥问题,为啥不能编译
//int prime = {2};
int prime;
for(size_t i = 0; i < number; ++i) prime = 2;
页:
[1]