Link_Ray 2017-07-30 12:03 采纳率: 60%
浏览 934
已采纳

各位大神帮忙看看为什么这个会无法编译,代码本身没有错误,就是无法编译


#include <iostream>
#include <string>
using namespace std;
string s;
string ori;
int cnt = 0;
bool expression_value();
bool term_value();
bool factor_value();


bool expression_value()
{
    bool result = term_value();
    char next;
    bool more = true;
    while(more)
    {
        next = ori[cnt];
        if(next == '&')
        {
            cnt++;
            bool next_expression = term_value();
            result = next_expression && result;
        }
        else if(next == '|')
        {
            cnt++;
            bool next_expression = term_value();
            result = next_expression || result;
        }
        else
            more = false;
    }
    return result;
}
bool term_value()
{
    bool result = factor_value();
    char next;
    bool more = false;
    while(more)
    {
        next = ori[cnt];
        if(next == ' ')
            continue;
        if(next == '&')
        {
            cnt++;
            bool next_expression = term_value();
            result = next_expression && result;
        }
        else if(next == '|')
        {
            cnt++;
            bool next_expression = term_value();
            result = next_expression || result;
        }
        else
            more = false;
    }
    return result;
}
bool factor_expression()
{
    bool result = false;
    char c;
    c=ori[cnt];
    if(c == '!')
    {
        cnt++;
        result = !result;
    }
    if(c == '(')
    {
        cnt++;
        result = expression_value();
        cnt++;
    }
    if(c == 'V')
        return true;
    if(c== 'F')
        return false;
    return result;
}
int main()
{
    int ncase=0;
    while(getline(cin,s))
    {
        ncase++;
        for(int i = 0;i<s.size();i++)
        {
            char ch = s[i];
            if(s[i]!=' ')
                ori+=ch;
        }
        bool result = expression_value();
        if(result)
            cout<<"Expression "<<ncase<<": V"<<endl;
        else
            cout<<"Expression "<<ncase<<": F"<<endl;
        ori.clear();
        cnt=0;
    }
    return 0;
}

提交到OJ上
无法编译,显示说我三个函数都是无定义,这是为什么??


  • 写回答

2条回答 默认 最新

  • 大米粥哥哥 2017-07-31 07:43
    关注

    main()上面的这个函数 bool factor_expression() 改成 bool factor_value();

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog