Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- int number;
- string line;
- getline(cin, line);
- istringstream stream(line);
- vector<int> numbers;
- while (stream >> number) {
- numbers.push_back(number);
- sumNumbers += number;
- }
- string command;
- cin >> command;
- int index1, index2;
- while (command != "end") {
- if (command == "decrease") {
- for (int i = 0; i < numbers.size(); i++) {
- numbers[i]--;
- }
- }
- else {
- cin >> index1 >> index2;
- if (command == "swap") {
- int value = numbers[index1];
- numbers[index1] = numbers[index2];
- numbers[index2] = value;
- }
- else {
- numbers[index1] *= numbers[index2];
- }
- }
- cin.ignore();
- cin >> command;
- }
- for (int i = 0; i < numbers.size(); i++) {
- cout << numbers[i] << (i < numbers.size() - 1 ? ", " : "");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement