高手帮帮忙,一个小程序不知道那错了!谢拉!
--------------------Configuration: PROG - Win32 Debug--------------------Compiling...
PROG.C
C:\WEXAM\00000000\PROG.C(12) : warning C4244: '=' : conversion from 'double ' to 'float ', possible loss of data
C:\WEXAM\00000000\PROG.C(14) : error C2043: illegal break
C:\WEXAM\00000000\PROG.C(17) : error C2065: 'returnx1' : undeclared identifier
C:\WEXAM\00000000\PROG.C(17) : error C2143: syntax error : missing ';' before '}'
Error executing cl.exe.
PROG.exe - 3 error(s), 1 warning(s)
--------------------------------------------------------------------------------------------------------
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
void writeDAT();
float countValue( )
{
float x0=0,x1=0.0;
while(1);
{
x0=x1;
x1=cos(x0);
if(fabs(x0-x1)<1e-6)
break;
}
returnx1
}
void main( )
{
system("CLS");
printf("实根=%f\n",countValue( ));
printf("%f\n",cos(countValue( ))-countValue( ));
writeDAT( );
}
void writeDAT( )
{
FILE *wf;
wf=fopen("out9.dat","w");
fprintf(wf,"%f\n",countValue( ));
fclose(wf);
}
用的是 Visual C++