Untitled

mail@pastecode.io avatar
unknown
c_cpp
a year ago
785 B
2
Indexable
#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;
			cin >> ss;
			if (ss == 'x') {
				cout << result << endl;
			}
			break;
		case('-'):
			result = x - y;
			if (ss == 'x') {
				cout << result << endl;
			}
			break;
		case('/'):
			result = float(x) / y;
			if (ss == 'x') {
				cout << result << endl;
			}
			break;
		case('*'):
			result = x * y;
			if (ss == 'x') {
				cout << result << endl;
			}
			break;
		default:
			break;
		}
	if (ss == '@') {
		x = result;
		cin >> ss;
		cin >> y;
	}
	}
	}