c++爆红求高人帮助
查看原帖
c++爆红求高人帮助
1391543
ljx201129楼主2024/7/22 21:20
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	char c;
	cin >> a >> b >> c;
	if (c != '+' && c != '-' && c != '*' && c != '/' )
	{
		cout << "Invalid operator!";
		return 0;
	}
	if (c = '+')
	{
		cout << a+b;
		return 0;
	}
	if (c = '-')
	{
		cout << a-b;
		return 0;
	}
	if (c = '*')
	{
		cout << a*b;
		return 0;
	}
	if (c = '/')
	{
		if (b = 0)
		{
			cout << "Divided by zero!";
			return 0;
		}
		else
		{
			cout << a/b;
			return 0;
		}
	}
	return 0;
}
2024/7/22 21:20
加载中...