Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
673 B
1
Indexable
Never
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int x;
	cin >> x;
	float result = 0;
	char ss;
	cin >> ss;
	int y;
	cin >> y;
	while(ss!='x'){
		if (y == 0) {
			cout << "error";
			break;
		}
		switch (ss)
		{
		case('+'):
			result = x + y;
			cout << result << endl;
			break;
		case('-'):
			result = x - y;
			cout << result << endl;
			break;
		case('/'):
			result = float(x) / y;
			cout << result << endl;
			break;
		case('*'):
			result = x * y;
			cout << result << endl;
			break;
		default:
			break;
		}
	cin >> ss;
	if (ss == '@') {
		x = result;
		cin >> ss;
		cin >> y;
	}
	}
	}