| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 777 人关注过本帖
标题:高手帮帮忙,一个小程序不知道那错了!谢拉!
只看楼主 加入收藏
wangyidj05
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-3-24
收藏
 问题点数:0 回复次数:2 
高手帮帮忙,一个小程序不知道那错了!谢拉!
--------------------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++
搜索更多相关主题的帖子: PROG 谢拉 WEXAM 
2008-04-01 22:44
now
Rank: 1
来 自:广州
等 级:新手上路
帖 子:544
专家分:0
注 册:2007-11-9
收藏
得分:0 
程序代码:
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
void writeDAT();

float countValue( )
{
float x0=0,x1=0.0;
do
{
     x0=x1;
     x1=cos(x0);
}while(fabs(x0-x1)>=1e-6);      //可改为do while循环;由于之前break违法;
     return x1;       //此处;
}

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);
}

GIS
Geographic Information System
你在哪里?——》你的坐标?
2008-04-01 23:18
wangyidj05
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-3-24
收藏
得分:0 
弄好了!太感谢拉!
2008-04-02 10:31
快速回复:高手帮帮忙,一个小程序不知道那错了!谢拉!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015281 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved