运行不了,高手帮改下!
--------------------Configuration: PROG - Win32 Debug--------------------Compiling...
PROG.C
C:\WEXAM\00000000\PROG.C(21) : warning C4013: 'isprime' undefined; assuming extern returning int
Linking...
PROG.OBJ : error LNK2001: unresolved external symbol _isprime
Debug/PROG.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
PROG.exe - 2 error(s), 1 warning(s)
----------------------------------------------------------------------------------------------------------
#include<stdio.h>
int cnt,sum;
void writeDAT();
int isPrime(int number)
{
int i,tag=1;
if(number==1)
return 0;
for(i=2;tag && i<=number/2;i++)
if(number % i==0) tag=0;
return tag;
}
void countValue()
{
int i;
cnt=0;
sum=0;
for(i=2;i<90;i++)
if(isPrime(i)&&isPrime(i+4)&&isPrime(i+10))
{
cnt++;
sum+=i;
}
}
void main()
{
cnt=sum=0;
countValue();
printf("满足条件的整数的个数=%d\n",cnt);
printf("满足条件的整数的和值=%d\n",sum);
writeDAT();
}
void writeDAT()
{
FILE *fp;
fp=fopen("out91.dat","w");
fprintf(fp,"%d\n%d\n",cnt,sum);
fclose(fp);
}
弄好了,谢版主, 呵呵!
[[it] 本帖最后由 wangyidj05 于 2008-4-11 12:41 编辑 [/it]]