程序有按键的计算器,超好用(其实很简陋)

资源地址:

程序有按键的计算器,超好用(其实很简陋)

运行图:

程序有按键的计算器,超好用(其实很简陋)_第1张图片
当然你直接写代码也行

#include
#include
using namespace std;
 
int main()
{
	system("color 2E");
	int a, b;
	char ch;
y:
	cout << "请输入算式:" << endl;
	cin>>a
		>>ch
		>>b;
	if (ch != '+' && ch != '-' && ch != '*' && ch != '/' && ch != '%')
	{
		printf("Error\n");
	}
	else
	{
		cout<< a<<" " << ch <<" "<<b << " = ";
	}
	switch (ch)
	{
	case '+':
	{
		cout << a + b << endl;
		break;
	}
	case '-':
	{
		cout  << a - b << endl;
		break;
	}
	case '*': 
	{
		cout << a * b << endl;
		break;
	}
	case '/': 
	{
		cout << a / b << endl;
		break;
	}
	case '%':
	{
		cout << a % b << endl;
		break; 
	}
	}
	goto y;
}

你可能感兴趣的:(C++,小窍门,计算器,青少年编程,小程序,windows,c++)