请各位C++高手指点一下啊,哪里有错误,在线等

来源:百度知道 编辑:UC知道 时间:2024/07/04 21:01:24
#include <iostream.h>
#include <stdio.h>
#include<stdlib.h>
#include<malloc.h>
const int MAX=10;
typedef struct
{
int stacksize;
int *base;
int *point;
int *top;
}Stack;
Stack S;
void initstack (Stack & S)
{
S.stacksize=MAX;
S.base=new int (S.stacksize);
S.top=S.base;
}

void push() //停入汽车
{
int icarnum;
int press;
int y=0,d=0;
int L[100];
loop3:
cout<<"请输入要停靠的车辆号码:";
cin>>icarnum;
if(S.top-S.base>=MAX)
{
cout<<"继续加入车辆请选择1,返回上级请按0。";
cout<<"停车场容量已满,请在过道等候."<<endl;
L[y]=icarnum;
y++;
loop4:
cin>>press;
switch(press)
{
case 1:goto loop3;break;
case 0:break;
default: cout<<"输入错误,请重新输入!"<<endl;goto loop4;

这程序我已调通了,我只指出错误的地方,有待楼主自己修正:

// 2.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<stdio.h>
#include <iostream.h>
#include <stdio.h>
#include<stdlib.h>
#include<malloc.h>
const int MAX=10;
typedef struct
{
int stacksize;
int *base;
int *point;
int *top;
}Stack;
Stack S;
void initstack (Stack & S)
{
S.stacksize=MAX;
S.base=new int (S.stacksize); //这里要用[]而不是()
S.top=S.base;
}

void push()
{
int icarnum;
int press;
int y=0,d=0;
int L[100];
loop3:
cout<<"请输入要停靠的车辆号码:";
cin>>icarnum;
if(S.top-S.base>=MAX)
{
cout<<"继续加入车辆请选择1,返回上级请按0。";
cout<<"停车场容量已满,请在过道等候."<<endl;
L[y]=icarnum;
y++;