看看这个行不??问题是你要什么样的表达式??
#include
#include
#include
#include
/*#include"stack.c"
#include"box.c"*/
#define MAXLEN1 100 /* 定义栈1的最大长度 */
#define MAXLEN2 100 /* 定义栈2的最大长度 */
#define NULL 0
#define OK 1
#define ERROR 0 /*定义出错信息 */
#define INFEASIBLE -1
#define ZEROOVERFLOW -2
#define OPTRERROR -3
#define SYERROR -4
#define POINTERROR -5
#define NOINPUT -6
typedef int Status;
enum boolean{FALSE,TRUE};
struct S1{
int top;
char element[MAXLEN1];
}; /*定义字符栈1的节点 */
typedef struct S1 *STACK1;
struct S2{
int top;
double element[MAXLEN2];
}; /*定义实数栈2的节点 */
typedef struct S2 *STACK2;*/
void main()
{
void setbkgnd();
void setsur();
void initespn(char ex[MAXLEN1]);
Status EXPRESSION(char e[MAXLEN1],double *p);/*求值函数,返回正确或错误信息,若正确,用p返回结果*/
void printresult(int con,double result);
char corewin(int lefttopx,int lefttopy);
char yorn;
double result; /*计算的结果*/
double *rp;
int count=1; /*标记进入循环体的次数*/
rp=&result;
do{
char espn[MAXLEN1]={\n,NULL};
Status expr;
yorn=NULL;
if(count==1) /*若是首次进入*/
{
setbkgnd();
setsur(); /*作初始画面*/
}
setbkgnd();
count++;
initespn(espn);
gotoxy(3,11);
expr=EXPRESSION(espn,rp);
printresult(expr,result);
yorn=corewin(3,13); /*提示继续或退出的窗口操作*/
}while(yorn!=e&&yorn!=E);
}
void setbkgnd()
{
void box1( int startx, int starty, int width, int high); /*画一个矩形线框*/
int j;
window(1,1,80,25);
textbackground(BLUE);
textcolor(WHITE);
clrscr();
box1(1,1,80,24);
gotoxy(2,2);
printf(" This is a program for calculating.\n");
gotoxy(2,3);
printf(" You are allowed to use these operators:\n");
gotoxy(2,4);
printf(" + - * / sin cos tan ln lg arcsin arccos arctan sqrt exp\n");
gotoxy(1,5);
putch(198);
for(j=1;j<79;j++)
putch(205);
putch(181);
gotoxy(1,12);
putch(195);
for(j=1;j<79;j++)
putch(0xc4);
putch(180);
gotoxy(1,14);
putch(198);
for(j=1;j<79;j++)
putch(205);
putch(181);
gotoxy(2,15);
printf("%cDirectories:",249);
gotoxy(3,16);
printf("%cinput the expression correctly,and the result will be given followed by the",250);
gotoxy(3,17);
printf(" postfix notation.");
gotoxy(3,18);
printf("%cif you dont input correctly,the information of the error will be given.",250);
gotoxy(3,19);
printf("%cpress c for continue or e for exit.",250);
gotoxy(3,20);
printf("%cpress Enter to confirm your choice.",250);
gotoxy(3,21);
printf("%cyou can change your choice before pressing Enter.",250);
gotoxy(3,22);
gotoxy(3,23);
}
void box1( int startx, int starty, int width, int high) /*画一个矩形线框*/
{
int i;
gotoxy(startx,starty);
putch(0xda); /*画-|*/
for(i=startx+1;i
putch(0xbf);
for(i=starty+1;i
gotoxy(startx,i);putch(0xb3); /*画|*/
gotoxy(width,i);putch(0xb3); /*画|*/
}
gotoxy(startx,high);
putch(0xc0); /*画|-*/
for(i=startx+1;i
putch(0xd9); /*画-|*/
}
void setsur()
{
void box2(int startx, int starty, int width, int high); /*画一个双矩形线框*/
window(21,8,60,16);
textbackground(LIGHTGRAY);
clrscr();
textcolor(WHITE);
box2(2,1,39,9);
textcolor(BLACK);
gotoxy(10,3);
cprintf("Expression Operating");
gotoxy(14,4);
cprintf("Version 1.1 ");
gotoxy(13,6);
cprintf("LKP&ZZC ID_27");
gotoxy(10,7);
cprintf("0003104_HIT 2002.5");
window(1,1,80,25);
gotoxy(2,6);
getch();
}
void box2( int startx, int starty, int width, int high) /*画一个双矩形线框*/
{
int i;
gotoxy(startx,starty);
putch(201); /*画|-*/
for(i=startx+1;i
putch(187);
for(i=starty+1;i
gotoxy(startx,i);putch(186); /*画|*/
gotoxy(width,i);putch(186); /*画|*/
}
gotoxy(startx,high);
putch(200); /*画|_*/
for(i=startx+1;i
putch(188); /*画_|*/
}
void initespn(char ex[MAXLEN1])
{
int i=1;
textcolor(YELLOW);
gotoxy(2,6);
cprintf("%cinput the expression:",249); /*提示输入表达式*/
gotoxy(3,7);
do
{
scanf("%c",&ex[i]);
i++;
}while(ex[i-1]!=\n); /*将表达式保存于字符数组中*/
}
发你私信了