1个回答
推荐于2016-03-30
展开全部
用cin.get()就可以
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "Calculator is preparing,please wait for about 3 seconds...";
unsigned long d;
d=3000;
_sleep(d);
cout << endl << endl;
cout << "Calculator's ready" << endl << endl;
cout << "Press enter to start";//触发1
cin.get();
cout << endl;
float a,b;
int c;
char s,s1,s2;
cout << "Enter the number of calculations: ";
cin >> c;
cout << endl;
for(int i=0;i<c;i++)
{
cout << "Please input expression: ";
cin >> a >> s >> b;
float jia=a+b,jian=a-b,cheng=a*b,chu=a/b,chengf=pow(a,b);
cout << "Answer is: ";
switch(s)
{
case '+':cout << jia;
break;
case '-':cout << jian;
break;
case '*':cout << cheng;
break;
case '/':cout << chu;
break;
case '^':cout << chengf;
break;
default:cout << "Error!";
}
cout << endl << endl;
}
cout << "Press enter to quit";
cin.get();
cin.get();//结束触发
return 0;
}
追问
OnKeyPress 用这个事件来实现的,有没有代码的?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询