打印

写了个小程序,不太对,请各位大神看看

[复制链接]
812|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jidian177|  楼主 | 2015-7-23 16:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include "led.h"
#include "delay.h"
#include "sys.h"
#include "stdio.h"
#include "math.h"
#include<stdlib.h>

struct ROOM
{
     double buf[3];
};

double f(double x)
{
double y;
y=sqrt(2*x+3);
return y;
}

struct ROOM diedai(double x0,double Error,u8 N)
{
double x1;
int i,k;
struct ROOM a;
u8 n=0;
for(k=0;k<N;k++)
  {x1=f(x0);
   if(fabs(x1-x0)<Error)
    {
        a.buf[0]=k;
        a.buf[1]=x1;
        a.buf[2]=n;
     break;
    }
   else x0=x1;//在这里赋值,进行递推
   n++;
  }
if(k>=N)
  {
  a.buf[0]=k;
  a.buf[1]=x1;
  a.buf[2]=n;
  }
  return a;
}
int main(void)
{
int i,j;
struct ROOM res;
        delay_init();                     //延时函数初始化          
        while(1)
        {
        res=diedai(4.0,0.1,15);
        }
}

相关帖子

沙发
1026869700| | 2015-7-28 08:57 | 只看该作者
连你的问题,这个程序的功能都没有写出来,而且程序的行对齐不清,让别人怎么帮你分析,看这样的程序很费劲的。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

4

帖子

0

粉丝