Untitled
unknown
plain_text
3 years ago
493 B
8
Indexable
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
char b;
int c, d;
cin >> a;
b = a[1];
if (a[0] == 'x') {
d = a[2] - '0';
c = a[4] - '0';
if (b == '-') cout << c + d;
else cout << c - d;
}
else if (a[2] == 'x') {
d = a[0] - '0';
c = a[4] - '0';
if (b == '-') cout << d - c;
else cout << c - d;
}
else {
d = a[0] - '0';
c = a[2] - '0';
if (b == '-') cout << d - c;
else cout << d + c;
}
}
Editor is loading...