blindsc 发表于 2005-5-18 19:30:58

[求助]cvi下如何调用子函数?

<P>程序及报错如下,敬请高手指教:</P>
<P>#include &lt;ansi_c.h&gt;                                    
#include &lt;math.h&gt;                                       
#define max 1000                                       
                                                         
zero(a,b)                                             
double a, b;                                          
{此处为错误1                                                   
int times=0;                                          
double x;                                             
do                                                   
   {                                                   
    x=(a+b)/2;                                          
    if((sin(x)*sin(a))&gt;0)                              
       a=x;                                             
      else                                             
       b=x;                                             
    if(times++&gt;max)                                    
      {                                                
       printf("too many times!\n");                     
       return ;                                          
       }                                                
   }while(fabs(a-b)&gt;1E-6);                           
                                                         
   if((sin(a)*sin(b))&lt;0)                              
       printf("zero=%1f\n",x);                           
       else                                             
       printf("There is no zero point!");               
      return;                                          
   }                                                   
                                                         
                                                         
   main( )                                             
   {                                                   
       double m, n;                                    
       printf("Input Datanumber: m=? n=?\n");            
       scanf("%1f%1f", &amp;m, &amp;n);                        
       zero(m,n); 此处为错误2                                       
      }                                                
                                                         
a.c - 2 errors
7, 3   Missing prototype.
37, 8   Missing prototype.
             </P>

game216 发表于 2005-5-18 21:38:35

void zero(double a,double b)

game216 发表于 2005-5-18 21:40:38

<P>没有返回值,就别加return了</P><P>return ; </P>

blindsc 发表于 2005-5-18 22:47:51

太感谢了!
页: [1]
查看完整版本: [求助]cvi下如何调用子函数?