Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> // DECLARING THE NEEDED ( ? ) LIBRARIES
- #include <fstream>
- #include <cmath>
- #include <iomanip>
- #include <sstream>
- #include <vector>
- #include <sstream>
- #include <cstdlib>
- #include <stdlib.h>
- #include <string>
- using namespace std; // USING THE STANDART NAMESPACE
- int main(){
- ifstream fd;
- fd.open("Duom2.txt");
- int n, v, h, m;
- fd >> n >> v >> h >> m;
- vector<double> s;
- vector<string> miestas;
- string line;
- while (getline(fd,line)) {
- if (line.empty()) continue;
- istringstream is(line);
- string word;
- while (is >> word) {
- if (isdigit(word[0])) {
- int val;
- stringstream ss(word);
- ss >> val;
- s.push_back(val);
- } else {
- miestas.push_back(word);
- }
- }
- }
- fd.close();
- double laikas = h * 60 + m;
- ofstream fr;
- fr.open("Rez2.txt");
- for ( int i = 0; i < n; i++ ) {
- double temp = s.at(i) / v * 60;
- laikas = laikas + temp;
- double valandos = trunc(laikas / 60);
- int temp2 = trunc(laikas);
- double minutes = temp2 % 60;
- fr << left << setw(12) << miestas.at(i) << right << setw(5) << valandos << " val. " << minutes << " min." << endl;
- }
- fr.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement