求助!!!数据结构问题.大家帮帮忙哦!别看我是菜鸟。。。。。。
来源:互联网 发布:hive sql 时间戳转换 编辑:程序博客网 时间:2024/05/02 04:21
括弧配对问题
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
#define MAXSIZE 100
typedef int ElemType;
typedef struct {
ElemType elem[MAXSIZE] ;
int top;
} SqStack;
SqStack *S;
void InitStack(SqStack *S)
{
S->top = 0;
}
void Push(SqStack *S, ElemType x) {
if (S->top>MAXSIZE)
printf("overflow/n");
else
{
S->elem[S->top]= x;
S->top ++;
}
}
ElemType Pop(SqStack *S)
{ElemType x;
if(S->top ==0)
{printf("underflow!");
x=-1;
}
else
{S->top--;
x=S->elem[S->top];
}
return x;
}
int GetTop(SqStack S,ElemType &x)
{
if(S.top==0)
{printf("underflow!");
x=-1;
}
else
x=*(S.top-1);
return x;
}
void kuohaopipei()
{
InitStack(S);
char ch;
ch=getchar();
while(ch!=NULL)
{
switch(ch)
{case ')':printf("Input error!/n");break;
case ']':printf("Input error!/n");break;
case '('ush(S,ch);break;
case '['ush(S,ch);break;
}
printf("%c",ch);
ch=getchar();
}
while(ch)
{
char ch;
ElemType x;
switch(Precede(GetTop(S),ch))
{
case '<'ush(S,ch);
ch=getchar();
break;
case '=':Pop(S,x);
ch=getchar();
break;
case '>':printf("Input error!/n");
break;
}
printf("%c",ch);
}
}
void main()
{S=(SqStack *)malloc(sizeof(SqStack));
InitStack(S);
Pop(S);
kuohaopipei();
getch();
}
四则运算问题
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
#define MAXSIZE 100
typedef int ElemType;
typedef struct {
ElemType elem[MAXSIZE] ;
int top;
} SqStack;
SqStack *S;
void InitStack(SqStack *S)
{
S->top = 0;
}
void Push(SqStack *S, ElemType x) {
if (S->top>MAXSIZE)
printf("overflow/n");
else
{
S->elem[S->top]= x;
S->top ++;
}
}
ElemType Pop(SqStack *S)
{ElemType x;
if(S->top ==0)
{printf("underflow!");
x=-1;
}
else
{S->top--;
x=S->elem[S->top];
}
return x;
}
int GetTop(SqStack S,ElemType &x)
{
if(S.top==0)
{printf("underflow!");
x=-1;
}
else
x=*(S.top-1);
return x;
}
char EvaluateExpression()
{
ElemType a,b,c;
InitStack(S);
Push(S,'#');
c=getchar();
while(c!='#' || GetTop(S)!='#')
{
if(!In(c,OP))
{
Push(S,c);
c=getchar();
}
else
{
Pop(S,b);
Pop(S,a);
Push(S,Operate(a,c,b));
c=getchar();
}
}
return GetTop(S);
}
void main()
{S=(SqStack *)malloc(sizeof(SqStack));
InitStack(S);
Pop(S);
EvaluateExpreession(S);
getch();
}
以上两个程序均有三个错误!!!希望有心人可以帮我修改,然后发到我的油箱里,十分感谢!!!油箱:fuxun2008@nwsuaf.edu.cn
791152837@qq.com
- 求助!!!数据结构问题.大家帮帮忙哦!别看我是菜鸟。。。。。。
- 我是个java 的初学者,我有个问题要问大家。请帮帮忙!
- (我是菜鸟)请教大家一个愚蠢的问题。。。。。。
- 我是菜鸟,大家多照顾
- 别看我是一只羊
- 大家好!我是一个菜鸟!!遇到问题了,请教大家帮我一下,急,谢谢了!!!
- 大家帮帮忙
- 大家帮帮忙!!!
- 大家帮帮忙
- 一个C++问题,请大家帮帮忙啊
- 我是菜鸟,请大家照顾咯!
- 求助!!数据结构问题
- 数据结构的问题求助
- 数据结构栈问题求助
- 我是刚进来的菜鸟,有些问题。希望大家多照顾 谢谢
- 求助 大虾们帮帮忙
- 比较简单的问题,但是我不会.大家帮帮忙吧!我是初学者!怎样用HIBERNATE和STRUTS把一条包含时间的数据插入ORACLE数据库中啊?
- 很奇怪的问题,什么病毒来的,大家帮帮忙~~~~~~
- Flex组件生命周期
- 不使用file控件,也能上传文件(转)
- Windows 下建立网络项目
- 诞生日
- 创建Xcode的工程模板和代码模板
- 求助!!!数据结构问题.大家帮帮忙哦!别看我是菜鸟。。。。。。
- USB控制传输在EZ-USB(68013)总结
- 马化腾关于产品设计和开发的内部讲座
- [转]最快排序和搜索算法的最简代码实现
- matlab 技巧 开心场~~~
- Aptana Studio 一个强大的开发js的IDE
- 不懂的东西太多了。
- Connector 作为一个Java项目解决的问题
- The " count " function in map (STL)