提交记录 #376
提交时间:2024-12-03 11:20:33
语言:c
状态:CompileError
编译情况:编译错误
code.c: In function ‘input’:
code.c:58:16: warning: zero-length gnu_printf format string [-Wformat-zero-length]
58 | printf("");
| ^~
code.c: At top level:
code.c:75:5: error: redefinition of ‘isPrim’
75 | int isPrim(int x){
| ^~~~~~
code.c:32:5: note: previous definition of ‘isPrim’ was here
32 | int isPrim(int x)
| ^~~~~~
固定测试点暂不可用
附加测试点暂不可用
51【大学】素数计数—用指针哦
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int*input(int n){
int*p=(int*)malloc(n*sizeof(int));
if(p==NULL){
printf("");
exit(1);
}
for (int i=0;i<n;i++){
scanf("%d",&p[i]);
}
return p;
}
int PrimCount(int*p,int n){
int count=0;
for(int i=0;i<n;i++){
if(isPrim(p[i])){
count++;
}
}
return count;
}
int isPrim(int x){
if(x==2)return 1;
if(x<=1||x%2==0)return 0;
for(int i=3;i<=sqrt(x);i+=2){
if(x%i==0)return 0;
}
return 1;
}