Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // testing.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <sstream>
- #include<queue>
- using namespace std;
- string A[100];
- int top = -1;
- int back = -1;
- bool isempty = true;
- queue<int> myq;
- void readFile(const char* filename) {
- ifstream inf(filename);
- string data;
- int i = 0;
- if (!inf) {
- cout << "the file is not open" << endl;
- }
- else {
- if (!inf.eof()) {
- while (getline(inf, data, ' ')) {
- int burst = stoi(data);
- myq.push(burst);
- top = top + 1;
- isempty = false;
- back = myq.size();
- }
- }
- cout << myq.front() << endl;
- cout << myq.back() << endl;
- }
- inf.close();
- }
- void outputFile(const char * filename) {
- ofstream out(filename);
- int size = myq.size();
- if (out) {
- for (int i = 1; i <= myq.size(); i++) {
- out << "job " << i << ", burst time: " << myq.front() << ", waiting time: " << myq.size()<<endl;
- myq.pop();
- }
- out << "job " << size << ", burst time: " << myq.back() << ", waiting time: " << myq.size() << endl;
- }
- out.close();
- }
- int main()
- {
- readFile("input2.txt");
- outputFile("output2.txt");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement