[問題] 問題出在哪??compile不過..
#include <stdio.h>
#include <stdlib.h>
#define Stacksize 80
#define TRUE 1
#define FALSE 0
int input_infix(char); // 中序轉後序
char priority(int); // 決定運算子優先順序
void evalute_subvalue(int); //計算程式
void Push_operand(struct stack_operand int*, int);//放值進運算元堆疊
void Push_operator(struct stack_operator char*, char);//放值進運算子堆疊
int Pop_operand(struct stack_operand int*);//拿運算元出堆疊
char Pop_operator(struct stack_operator char*);//拿運算元出堆疊
////////////////////////////////////
/* 運算元堆疊宣告 */
////////////////////////////////////
struct stack_operand
{
int top;
int stack[Stacksize];
};
////////////////////////////////////
/* 運算子堆疊宣告 */
////////////////////////////////////
struct stack_operator {
char top;
char stack[Stacksize];
};
////////////////////////////////////
/* 主程式 */
////////////////////////////////////
int main(void)
{
int input[Stacksize];
printf("輸入運算式:");
scanf("%s", input);
input_fix(input);
system("pause");
return 0;
}
////////////////////////////////////
/* 中序轉後序 */
////////////////////////////////////
int input_infix(char* infix)
{
int i=0;
char symb;
int op;
struct stack_operand ope_rand;
struct stack_operator oper_ator;
ope_rand.top = -1 ;
oper_ator.top = -1 ;
while(!'\0')
{ symb = infix[i];
if (symb = '+'||'-'||'*'||'/'){
Push_operator(*oper_ator.top, symb);
}
else
if (symb == ')')
{
while((op = Pop_operator(*oper_ator.top))!='(')
{
evalute_subvalue(op);
continue;
}}
else
while (priority(symb) <= priority(oper_ator.top))
{
op = Pop_operand(*ope_rand.top);
evalute_subvalur(op);
}
Push_operator(*oper_ator.top, symb);
while()
{
op = Pop_operand(*ope_rand.top);
evalute_subvalue(op);
}
printf("ans:%c",*ope_rand->stack[0]);
}
////////////////////////////////////
/* 判斷運算元優先順序 */
////////////////////////////////////
int priority(char symb)
{
int p;
switch(op) {
case '+': case '-':
p = 1;
break;
case '*': case '/':
p = 2;
break;
default:
p = 0;
break;
}
return p;
}
////////////////////////////////////
/* 計算函式 */
////////////////////////////////////
void evalute_subvalue(int op)
{
int a,b;
int op, new_value;
b = int Pop(*ope_rand.top);
a = int Pop(*ope_rand.top);
switch(op) {
case '+':
return (new_value = a + b);
case '-':
return (new_value = a - b);
case '*':
return (new_value = a * b);
case '/':
return (new_value = a / b);
}
Push(*ope_rand.top , new_value);
}
////////////////////////////////////
/* PUSH */
////////////////////////////////////
void Push_operand(struct stack_operand *ps , int symb)
{
if(ps.top >= Stacksize - 1)
printf("The stack is full \n");
retun FALSE
else
ps->stack[++(ps->top)] = symb;
return;
}
void Push_operator(struct stack_operator *ps , char symb)
{
if(ps.top >= Stacksize - 1)
printf("The stack is full \n");
retun FALSE;
else
ps->stack[++(ps->top)] = symb;
return;
}
////////////////////////////////////
/* POP */
////////////////////////////////////
int Pop_operand(struct stack_operand *ps)
{
if(ps.top < 0)
printf("The stack is empty \n");
retun FALSE;
else
return(ps->stack[ps->top --]);
}
int Pop_operator(struct stack_operator *ps)
{
if(ps.top < 0)
printf("The stack is empty \n");
retun FALSE;
else
return(ps->stack[ps->top --]);
}
小弟這個程式一直沒辦法compile...
可是我找不到錯誤到底在哪...
是語法有錯嗎??
還是其他的問題呢??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.25.205
推
04/06 13:13, , 1F
04/06 13:13, 1F
→
04/06 13:14, , 2F
04/06 13:14, 2F
推
04/06 15:17, , 3F
04/06 15:17, 3F
→
04/06 15:18, , 4F
04/06 15:18, 4F
→
04/06 15:32, , 5F
04/06 15:32, 5F
→
04/06 15:33, , 6F
04/06 15:33, 6F
→
04/06 15:34, , 7F
04/06 15:34, 7F
→
04/06 15:35, , 8F
04/06 15:35, 8F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章