Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <queue>
- using namespace std;
- int main() {
- fstream input("input.txt");
- if (!input.is_open()) {
- cout << "file not found" << endl;
- return 0;
- }
- queue<int> values;
- int tmp, value;
- while (!input.eof()) {
- input >> tmp;
- values.push(tmp);
- }
- input.close();
- const size_t iterations = values.size();
- for (size_t i = 0; i < iterations; i++) {
- tmp = values.front();
- cout << tmp << " ";
- values.pop();
- values.push(tmp);
- }
- cout << endl;
- cout << endl;
- cout << "Enter the value, you want to change = ";
- cin >> tmp;
- cout << "Enter the value you want to assign = ";
- cin >> value;
- for (size_t i = 0; i < iterations; i++) {
- int reassign = values.front();
- values.pop();
- if (reassign == tmp)
- values.push(value);
- else
- values.push(reassign);
- }
- cout << endl;
- for (size_t i = 0; i < iterations; i++) {
- tmp = values.front();
- cout << tmp << " ";
- values.pop();
- values.push(tmp);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement