Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
1.4 kB
1
Indexable
Never
#include <iostream>
#include <string>
int main()
{
    long long a,b,answer = 0,buffer = 0,count = 0;
    char opera;

	char name = ']';

	while(name != 'x') {
		
		std::cin >> name;
		if (count / 2 == 0) {
			switch (name)
			{
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				if (count == 0) {
					answer = (int)name - '0';
					std::cout << answer << "\n";
					break;
				}
				else {
					buffer = (int)name - '0';
				}
				
				break;

			case '@': {
				buffer = answer;
				break;
			}
			default:
				buffer = 0;
				break;
			}
			if (count > 2) {
				
				switch (opera) {
				case '+': {
					answer += buffer;
					
					break;
				}case '-': {
					answer -= buffer;
					break;
				}case '*': {
					answer *= buffer;
					break;
				}case '/':{
					answer /= buffer;
					break;
				}
				default: {
					break;
				}
				}
				std::cout << answer << " " << opera << " " << buffer << "\n";
			}

			
		}
		else {
			switch (name)
			{
			case '+': {
				opera = '+';
				break;
			}
			case '-': {
				opera = '-';
				break;
			}
			case '/': {
				opera = '/';
				break;
			}
			case '*': {
				opera = '*';
				break;
			}
			default:
				break;
			}

		}
		count += 1;
		
	}
	

	
}