unexpected end of file found
#include "stdlib.h"
#include "string.h"
#include "iostream.h" #include "stdafx.h" #define MAX 100
typedef struct //声明堆栈结构
{
int stack[MAX]; //栈顶指针
int top; //栈顶数据
}sqstack;
sqstack operator,operand;
//存入堆栈数据
int push(sqstack *s,int value)
{
if(s->top=MAX-1)
return 0;
s->top++;
s->stack[s->top]=value;
return 1;
}
//从堆栈中取出数据
int pop(sqstack *s)
{
int x;
if(s->top<0)
return NULL;
x=s->stack[s->top];
s->top--;
return x;
}
//检查堆栈是否为空
int empty(sqstack *s)
{
if(s->top<0)
return 1;
else
return 0;
}
//判断是否为运算符
int is_oprator(char operator)
{
switch(operator) //operator是运算符
case '+': case'-': case '*': case '/':
return 1;
default:
return 0;
}
//判断运算符的优先权
int priority(char operator)
{
switch(operator)
{
case '+': case'-':
return 1;break;
case '*': case '/':
return 2;break;
default:return 0;
}
}
//计算任意两个操作数的值
int two_result(int operator,int operand1,int operand2)
{
switch(operator)
{
case '+':return (operand1+operand2);
case '-':return (operand1-operand2);
case '*':return (operand1*operand2);
case '/':return (operand1/operand2);
}
}
//主程序,输入中序表达式后计算出表达式的结果值
void main()
{
char expreession[100];
int position=0;
int op=0;
int operand1=0;
int operand2=0;
operator->top=operand->=-1;
cout<<endl;
cout<<"Please input the inorder expression:";
gets(expression);
while(expression[position]!='\0'&&expression[position]!='\n')
{
if(is_operator(expression[position]))
{
if(!empty(oparetor))
while(priority(expression[position])<=priorty(operator->data)&&!empty(operator))
{
operand1=pop(operand);
operand2=pop(operand);
op=pop(operator);
oprand=push(operand,two_result(op,operand1,operand2);
}
operator=push(operator,expression[position]);
}
else
operand=push(operand,expression[position]-48);
position++;
}
while(!empty(operator))
{
op=pop(operator);
oprand1=pop(operand);
oprand2=pop(operand);
operand=push(operand,two_result(op,operand1,operand2));
}
evaluate=pop(operand);
cout<<"The expression["+expression+"] result is '"+evaluate+"'"<<endl;
}
求中序表达式程序
运行出现unexpected end of file found错误
#include "string.h"
#include "iostream.h" #include "stdafx.h" #define MAX 100
typedef struct //声明堆栈结构
{
int stack[MAX]; //栈顶指针
int top; //栈顶数据
}sqstack;
sqstack operator,operand;
//存入堆栈数据
int push(sqstack *s,int value)
{
if(s->top=MAX-1)
return 0;
s->top++;
s->stack[s->top]=value;
return 1;
}
//从堆栈中取出数据
int pop(sqstack *s)
{
int x;
if(s->top<0)
return NULL;
x=s->stack[s->top];
s->top--;
return x;
}
//检查堆栈是否为空
int empty(sqstack *s)
{
if(s->top<0)
return 1;
else
return 0;
}
//判断是否为运算符
int is_oprator(char operator)
{
switch(operator) //operator是运算符
case '+': case'-': case '*': case '/':
return 1;
default:
return 0;
}
//判断运算符的优先权
int priority(char operator)
{
switch(operator)
{
case '+': case'-':
return 1;break;
case '*': case '/':
return 2;break;
default:return 0;
}
}
//计算任意两个操作数的值
int two_result(int operator,int operand1,int operand2)
{
switch(operator)
{
case '+':return (operand1+operand2);
case '-':return (operand1-operand2);
case '*':return (operand1*operand2);
case '/':return (operand1/operand2);
}
}
//主程序,输入中序表达式后计算出表达式的结果值
void main()
{
char expreession[100];
int position=0;
int op=0;
int operand1=0;
int operand2=0;
operator->top=operand->=-1;
cout<<endl;
cout<<"Please input the inorder expression:";
gets(expression);
while(expression[position]!='\0'&&expression[position]!='\n')
{
if(is_operator(expression[position]))
{
if(!empty(oparetor))
while(priority(expression[position])<=priorty(operator->data)&&!empty(operator))
{
operand1=pop(operand);
operand2=pop(operand);
op=pop(operator);
oprand=push(operand,two_result(op,operand1,operand2);
}
operator=push(operator,expression[position]);
}
else
operand=push(operand,expression[position]-48);
position++;
}
while(!empty(operator))
{
op=pop(operator);
oprand1=pop(operand);
oprand2=pop(operand);
operand=push(operand,two_result(op,operand1,operand2));
}
evaluate=pop(operand);
cout<<"The expression["+expression+"] result is '"+evaluate+"'"<<endl;
}
求中序表达式程序
运行出现unexpected end of file found错误
...全文
相关推荐
vc提示unexpected end of file found的原因分析
首先,当出现“unexpected end of file found”错误时,首先要检查的是预编译指令。
C++常见错误中英文对照表
#### 2. fatal error C1004: Unexpected end of file found- **英文描述**: `fatal error C1004: unexpected end
C++实验常见出错信息
**致命错误 (fatal error)** - **C1004**: 出现“unexpected end of file found”这类错误通常是由于代码中的花括号不匹配。
C++常见错误
2. fatal error C1004: unexpected end of file found中文对照:编译错误,文件未结束分析:一个函数或者一个结构定义缺少“}”,或者在一个函数调用或表达式中括号没有配对出现
VC++6.0常见错误提示
#### 二、fatal error C1004: unexpected end of file found- **中文对照**:(编译错误)文件未结束- **分析**:这类错误通常出现在以下几种情况:


