当前位置:我的异常网» C语言 » C語言 怎么案ESC鍵回原問題
C語言 怎么案ESC鍵回原問題
www.myexceptions.net 网友分享于:2013-03-04 浏览:43次
C語言 如何案ESC鍵回原問題
這是一道先乘除後加減的編程(按下 '= '鍵會算出答案)
題目:
在按下 '= '鍵之前 按下 'ESC ' 會回到原題目
在算出答案後 按任何建繼續 按 'ESC '回中程序
不知道哪為大大可以幫我改一下
以下是先乘除後加減的編程 要把它加上題目說的
#include
#include
//prototypes
char GetInteger(int* x);
int main(int argc, char *argv[])
{
//declare variables
char state; //to the state of the state machine
int x, x1, x2, x3, result;
char op, op1;
int repeat;
//explain the program
printf( "Welcome to the single-digit calculator ");
printf( "with multiplication.\n\n ");
state = 'F '; //enter state F initially
repeat = 'y '; //enter the loop initially
while(repeat == 'y ' || repeat == 'Y ')
{
switch(state)
{
case 'F ':
//state F: prompt user for input
//and leave for state A unconditional
printf( "Please input the equation:\n ");
state = 'A '; //update the state
break;
case 'A ':
case 'B ':
//op,x
//and leave for state C on op1=op; x1=x
文章评论