#include "math.h"好象是这个吧:)

解决方案 »

  1.   

    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>void main( void )
    {
       double question = 45.35, answer;   answer = sqrt( question );
       if( question < 0 )
          printf( "Error: sqrt returns %.2f\n, answer" );
       else
          printf( "The square root of %.2f is %.2f\n", question, answer );
    }
    OutputThe square root of 45.35 is 6.73
      

  2.   

    xt_jat(桑巴) 说的对(我就不要分了),我以前也碰到过这种情况,不知道为什么能编译通过。
      

  3.   

    #include "math.h"you can try!
      

  4.   

    加上#include "math.h"后减少了一个错误,仍然存在
    4 error(s), 1 warning(s)
    主要问题是调试时,x竟然不会赋值为144.0,我做其他的题目没有用到math.h也会出现类似的情况:
    // TODO: add draw code for native data here
             int a;
    int b;
    int c;
    int d,nTemp;
    a=10;
    b=7;
    c=5;
    if(a>b)
    d=a;
    else
    d=b;
    if(c>d)
    {
    nTemp=c;
        c=d;
    d=nTemp;
    }
    cString strOutput;
    strOutput.format("最大数是:%d",d);
    pDC->TextOut(0,0,strOutput);
    }
    也是几个变量不能按我的意图正常赋值!
    是不是我在使用VC6.0时方法不正确?
    我以上代码是加在视图类的OnDraw函数下的。另外我觉得使用VC环境与在Borland C++中好象很不一样。
    比如,我要编一个小程序,在VC++中应该用什么步骤?
    不好意思刚学习,让大家见笑了!
      

  5.   

    用向导,另外看看侯捷的《MFC深入浅出》
      

  6.   

    VC中建立一个小的测试程序完全可以不用“文档——视图”这么复杂的工程,你可以建立一个WIN 32 控制台(win32 console application)应用程序,在工程里添加一个源文件(注意此文件里一定要有一个main()函数),调试执行就可以了,至于你的错误,我还不知是怎么回事,待我试过再答
      

  7.   

    我试过了,并没出任何问题啊,你的变量是在哪里出的错?是不是在其他地方还有引用?只在OnDraw里用的话,不应该打不出的,我的程序里随便添了几句和你代码一样的东东,一点问题也没有
      

  8.   

    to  crazy_lazy_pig(疯狂懒猪) 
    我按你的方法建立一个WIN 32 控制台(win32 console application)应用程序,在工程里添加一个源文件(Source Files),为何不能调试运行?而且命令也不会变成蓝色,全是黑色的,我又哪里做错了?添加的代码如下:#include <stdio.h>void main(void)
        int a;
    int b;
    int c;
    int d,nTemp;
    a=10;
    b=7;
    c=5;
    if(a>b)
    d=a;
    else
    d=b;
    if(c>d)
    {
    nTemp=c;
        c=d;
    d=nTemp;
    }
    cString strOutput;
    strOutput.format("最大数是:%d",d);
    pDC->TextOut(0,0,strOutput);
    }
      

  9.   

    原因很简单,那个X已不能用作变量,
    你在某处使用了#define X ...
    比如说你可能不小心将某ID号定义成了X
    查看一下resource.h等中是否有这么一句?
      

  10.   

    I can not agree u more!
      

  11.   

    我已经找到问题了:
    是cstring和format没有大写
    谢谢大家!