Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication187.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <vector>
- #include <string>
- #include <iterator>
- #include <algorithm>
- int main()
- {
- std::vector<char> opStack;
- std::vector<std::string> operand;
- bool operandGefunden = false;
- std::string holder;
- std::string inputString;
- std::cout << "Rechnung eingeben..." << std::endl;
- std::getline(std::cin, inputString);
- std::string::iterator end_point = std::remove(inputString.begin(), inputString.end(), ' ');
- inputString.erase(end_point, inputString.end());
- int found = inputString.find_last_of("+-*/");
- for (int i = 0; i < inputString.size(); i++)
- {
- if (inputString[i] != '+' && inputString[i] != '-' && inputString[i] != '*' && inputString[i] != '/')
- {
- holder.push_back(inputString[i]);
- }
- else
- {
- if (i == found)
- {
- opStack.push_back(inputString[i]);
- operand.push_back(holder);
- holder == "";
- operand.push_back({ inputString.begin() + i + 1, inputString.end() });
- break;
- }
- opStack.push_back(inputString[i]);
- operand.push_back(holder);
- holder = "";
- }
- }
- std::cout << "operatoren" << std::endl;
- for (auto a : opStack)
- {
- std::cout << a << " ";
- }
- std::cout << std::endl;
- std::cout << "Operanden:" << std::endl;
- for (auto a : operand)
- {
- std::cout << a << " ";
- }
- std::cout << std::endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement