| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1480 人关注过本帖
标题:高手们,帮我看一下这是啥意思!
只看楼主 加入收藏
ylx
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2010-8-12
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:24 
高手们,帮我看一下这是啥意思!
编完一个程序,编译后结果是:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
Linking...
Cpp1.obj : error LNK2001: unresolved external symbol "double __cdecl Caculater(struct char_double,short *,short *)" (?Caculater@@YANUchar_double@@PAF1@Z)
Debug/Cpp1.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

Cpp1.exe - 1 error(s), 0 warning(s)
诊断一下,谢谢!!!
搜索更多相关主题的帖子: warning double 
2010-08-12 22:31
jack10141
Rank: 11Rank: 11Rank: 11Rank: 11
来 自:陕西西安
等 级:小飞侠
威 望:6
帖 子:706
专家分:2271
注 册:2010-8-10
收藏
得分:2 
连接错误 连接到Caculater出错

Coding就像一盒巧克力,你永远不会知道你会遇到什么BUG
别跟我说你是不能的,这让我愤怒,因为这侮辱了你的智慧
2010-08-12 22:54
erikyo
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:2
帖 子:270
专家分:1154
注 册:2010-6-10
收藏
得分:2 
看这个不太有头绪,还是把代码贴出来吧~
2010-08-13 08:39
ylx
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2010-8-12
收藏
得分:0 
我是打算编一下简易计算器,C语言还是刚学的,只是想练一下刚学的知识,算法可能不太好,高手们可别笑话我这菜鸟哈!
程序很长麻烦耐心帮忙看看,有啥错误或能改进的请多多指教!!!!
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<math.h>
char operator_str[]={'+','_','*','/','^','@','!','s','c','t','S','C','T'};   /*存放合法符号,便于比较*/
char input[256];  /*储存用户输入的算式*/
double result=0.0;
short *right=NULL,*left=NULL,YN=1; /*指针记录左右括号的位置*/
unsigned short i=0,j=0 ,k=0,count=0;
struct char_double
{
    char Operator;
    double num;
};
typedef struct char_double mytype;
mytype dealing[256];
double Caculater(struct char_double,short*,short*);
long fact(long);
void main()
{   
    printf("计算器说明:"
           "\n\t1.该计算器支持+、-、*、/、^、!、@等基本运算;"
           "\n\t2.适当时候可以使用()来帮助表达,算式输完按ENTER键即可;"
           "\n\t3.\"^\"表示指数运算;\"s,c,t\"分别表示正弦、余弦、正切;"
           "\n\t  大写(S、C、T)表示相应的反三角函数;\"!\"表示阶乘运算;\"a@b\"表示以a为底的b的对数."
           " \n 请输入计算式:");
wrong:    while(strcmp(gets(input),"quit")!=0)
    {
   /*对用户输入的算式进行格式化处理*/
      for(i=0,count=0;i<strlen(input);i++)
          if(strchr(operator_str,input[i])!=NULL)
          {
              if(YN==0) YN=1;
              count++;
          }
          else if((isdigit(input[i]))&&YN) count++;
      count++;
      for(i=0,j=1,YN=1;i<strlen(input);i++)   /*第一个位置预留,便于使用前次结果参与计算时存放前次运算结果*/
          if(strchr(operator_str,input[i])!=NULL)
          {
              if(YN==0) YN=1;
              dealing[j++].Operator=input[i];
          }
          else if((isdigit(input[i]))&&YN)
          {
              dealing[j++].num=atof(input+i);
              YN=0;
          }
    /*以上步骤得到了double型数字和运算符组成的数据
    ···················
      分析第一个字符是否是=号*/
      if(dealing[1].Operator!='\0') dealing[0].num=result;
      else dealing[0].Operator='$';                          /*$表示失效数据*/
      /*对算式中的括号进行由里到外,从左到右的处理*/
      int number1=0,number2=0;
      do
      {
          for(i=1;i<count;i++)
          {
              if(dealing[i].Operator=='(') ++number1;  /*得到算式中括号的个数*/
              else if(dealing[i].Operator==')') ++number2;
          }
          if(number1!=number2)
          {
              printf("  算式不合法,括号使用不正确!\n\t请重新输入:");
              goto wrong;
          }
          if(number1!=0)
          {
            right=(short*)malloc(number1);
            left=(short*)malloc(number2);
            for(k=1,i=0,j=0;k<count;k++) /*找到括号的确切位置*/
            {
              if(dealing[k].Operator=='(') *(left+i++)=k;
              else if(dealing[k].Operator==')') *(right+j++)=k;
            }
            /*处理的目标括号为第一个“)”(即*right)和其左边出现的最后一个“(”(即下面得到的*(left+k-1))组成的括号*/  
            for(k=0;k<number1;k++) if(*(left+k)>*right) break;
            left=left+k-1;
            /*对()的运算式进行处理*/
            result=Caculater(dealing[256],right,left);    /*通过调用计算函数赋给result*/
            /*更新pm,为再次进行去括号做好准备*/
            dealing[*left].num=result;
            for(i=*left+1;i<*right+1;i++) dealing[i].Operator='$';
          }

      }while(number1);
    /*经过do-while循环最终得到一个没有括号的计算式,最后一次调用Caculator的到最终结果*/
      result=Caculater(dealing[256],dealing,&dealing[count].Operator);  /*最后一次调用时处理对象为整个输入计算式长度*/
     /* printf("=%f\n  请再次输入计算式(运算式以运算符开始表示利用上次结果):",result);*/
      printf("=%.4f.\n\t请输入计算式:",result);

    }
}
double Caculater(mytype dealing[],short *right,short *left)
{
 short big=*right,little=*left,i=0,j=0;
 char letters[]={'!','^','@','s','c','t','S','C','T'};   /*存放运算符,便于比较*/
 double math1=0.0,math2=0.0;
 for(i=little+1;i<big;i++)   /*处理优先级较高的运算符*/
     if(strchr(letters,dealing[i].Operator)!=NULL)
     {
         switch(dealing[i].Operator)
         {
         case '!':
             for(j=i-1;j>little;j--)
                 if(dealing[j].Operator=='\0') /*dealing[j].Operator='\0'(默认初始值为'\0')时说明dealing[i].num有效*/
                 {
                   dealing[j].num=(double)fact((long)dealing[i].num); /*运算结果储存在本次运算的运算数的dealing[i].num里*/
                   break;
                 }
         case '^':
             {
             for(j=i-1;j>little;j--)
                 if(dealing[j].Operator=='\0')
                 {
                     math1=dealing[j].num;
                     dealing[j].Operator='$';  /*处理过的数据标记为无效*/
                     break;
                 }
             for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                     math2=dealing[j].num;
                     break;
                 }
             dealing[j].num=pow(math1,math2);
             math1=0.0;
             math2=0.0;
             }
         case '@':
             {
             for(j=i-1;j>little;j--)
                 if(dealing[j].Operator=='\0')
                 {
                     math1=dealing[j].num;
                     dealing[j].Operator='$';
                     break;
                 }
             for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                     math2=dealing[j].num;
                     break;
                 }
             dealing[j].num=log(math2)/log(math1);
              math1=0.0;
             math2=0.0;
             }
         case 's':
             for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                   dealing[j].num=sin(dealing[i].num*3.141592/180.0);
                   break;
                 }
         case 'c':
             for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                   dealing[j].num=cos(dealing[i].num*3.141592/180.0);
                   break;
                 }
         case 't':
             for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                   dealing[j].num=tan(dealing[i].num*3.141592/180.0);
                   break;
                 }
         case 'S':
             for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                   dealing[j].num=asin(dealing[i].num*3.141592/180.0);
                   break;
                 }
         case 'C':
             for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                   dealing[j].num=acos(dealing[i].num*3.141592/180.0);
                   break;
                 }
         case 'T':
             for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                   dealing[j].num=atan(dealing[i].num*3.141592/180.0);
                   break;
                 }
         dealing[i].Operator='$';
         }
     }
  for(i=little+1;i<big;i++)   /*乘除运算*/
  {
     if(dealing[i].Operator=='*')
     {
         for(j=i-1;j>little;j--)
             if(dealing[j].Operator=='\0')
                 {
                     math1=dealing[j].num;
                     dealing[j].Operator='$';
                     break;
                 }
         for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                     math2=dealing[j].num;
                     break;
                 }
         dealing[j].num=math1*math2;
         dealing[i].Operator='$';
     }
     if(dealing[i].Operator=='/')
     {
         for(j=i-1;j>little;j--)
             if(dealing[j].Operator=='\0')
                 {
                     math1=dealing[j].num;
                     dealing[j].Operator='$';
                     break;
                 }
         for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                     math2=dealing[j].num;
                     break;
                 }
         dealing[j].num=math1/math2;
         dealing[i].Operator='$';
         math1=0.0;
         math2=0.0;
     }
  }
  for(i=little+1,j=0;i<big;i++)  /*处理加减运算*/
  {
       if(dealing[j].Operator=='+')
     {
         for(j=i-1;j>little;j--)
             if(dealing[j].Operator=='\0')
                 {
                     math1=dealing[j].num;
                     dealing[j].Operator='$';
                     break;
                 }
         for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                     math2=dealing[j].num;
                     break;
                 }
         dealing[j].num=math1+math2;
         dealing[i].Operator='$';
         math1=0.0;
         math2=0.0;
     }
     if(dealing[i].Operator=='-')
     {
         for(j=i-1;j>little;j--)
             if(dealing[j].Operator=='\0')
                 {
                     math1=dealing[j].num;
                     dealing[j].Operator='$';
                     break;
                 }
         for(j=i+1;j<big;j++)
                 if(dealing[j].Operator=='\0')
                 {
                     math2=dealing[j].num;
                     break;
                 }
         dealing[j].num=math1-math2;
         dealing[i].Operator='$';
     }
  }
return  dealing[j].num; /*最后一次进行的加\减运算结果即运算结果*/
}
long fact(long N)  /*阶乘函数*/
{
    long i=0,total=0;
    for(i=N;i>0;)
        total=total*i--;
    return total;
}
2010-08-13 10:26
succubus
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:4
帖 子:635
专家分:1080
注 册:2007-10-7
收藏
得分:16 
好长
待我慢慢看来


[ 本帖最后由 succubus 于 2010-8-13 10:34 编辑 ]

[url=http:///view/aDU1]/image/aDU1.gif" border="0" />[/url]
2010-08-13 10:33
succubus
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:4
帖 子:635
专家分:1080
注 册:2007-10-7
收藏
得分:0 
typedef struct char_double mytype;
double Caculater(struct char_double,short*,short*);
double Caculater(mytype dealing[],short *right,short *left){...}

[url=http:///view/aDU1]/image/aDU1.gif" border="0" />[/url]
2010-08-13 10:38
ylx
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2010-8-12
收藏
得分:0 
开始我也是这么认为,改过之后过了,结果一样!
2010-08-13 10:46
ylx
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2010-8-12
收藏
得分:0 
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
D:\VC6SP6\vc files\计算器\Cpp1.cpp(82) : error C2664: 'Caculater' : cannot convert parameter 1 from 'struct char_double' to 'struct char_double []'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
D:\VC6SP6\vc files\计算器\Cpp1.cpp(90) : error C2664: 'Caculater' : cannot convert parameter 1 from 'struct char_double' to 'struct char_double []'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
执行 cl.exe 时出错.

Cpp1.exe - 1 error(s), 0 warning(s)
2010-08-13 10:48
succubus
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:4
帖 子:635
专家分:1080
注 册:2007-10-7
收藏
得分:0 
咋改得?更新代码。。。
而且你这个函数调用本身就有问题
result=Caculater(dealing[256],dealing,&dealing[count].Operator);  /*最后一次调用时处理对象为整个输入计算式长度*/
第一个参数先不提了,第二个参数咋能是dealing呢,你声明的不是short*吗。。。

[url=http:///view/aDU1]/image/aDU1.gif" border="0" />[/url]
2010-08-13 10:56
ylx
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2010-8-12
收藏
得分:0 
回复 9楼 succubus
那个确实有问题,我要改,你看一下到底为啥不能调用
2010-08-13 10:58
快速回复:高手们,帮我看一下这是啥意思!
数据加载中...
 
   



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

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