提交记录 #284
提交时间:2024-11-19 19:19:12
语言:c
状态:CompileError
编译情况:编译错误
code.c:30:6: error: conflicting types for ‘isPrime’
30 | void isPrime(int n){
| ^~~~~~~
code.c:8:6: note: previous declaration of ‘isPrime’ was here
8 | int isPrime( int ); // 若是素数函数isPrim返回1,否则返回0
| ^~~~~~~
code.c: In function ‘isPrime’:
code.c:31:20: warning: ‘return’ with a value, in function returning void [-Wreturn-type]
31 | if(n<=0)return 0;
| ^
code.c:30:6: note: declared here
30 | void isPrime(int n){
| ^~~~~~~
code.c:32:20: warning: ‘return’ with a value, in function returning void [-Wreturn-type]
32 | if(n==2)return 1;
| ^
code.c:30:6: note: declared here
30 | void isPrime(int n){
| ^~~~~~~
code.c:33:22: warning: ‘return’ with a value, in function returning void [-Wreturn-type]
33 | if(n%2==0)return 0;
| ^
code.c:30:6: note: declared here
30 | void isPrime(int n){
| ^~~~~~~
code.c:35:26: warning: ‘return’ with a value, in function returning void [-Wreturn-type]
35 | if(n%i==0)return 0;
| ^
code.c:30:6: note: declared here
30 | void isPrime(int n){
| ^~~~~~~
code.c:37:12: warning: ‘return’ with a value, in function returning void [-Wreturn-type]
37 | return 1;
| ^
code.c:30:6: note: declared here
30 | void isPrime(int n){
| ^~~~~~~
固定测试点暂不可用
附加测试点暂不可用
42【中学】孪生素数(编子函数)
void isPrime(int n){
if(n<=0)return 0;
if(n==2)return 1;
if(n%2==0)return 0;
for (int i=3;i<=sqrt(n);i+=2){
if(n%i==0)return 0;
}
return 1;
}