Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <iostream> // DECLARING THE NEEDED ( ? ) LIBRARIES
  2. #include <fstream>
  3. #include <cmath>
  4. #include <iomanip>
  5. #include <sstream>
  6. #include <vector>
  7. #include <sstream>
  8. #include <cstdlib>
  9. #include <stdlib.h>
  10. #include <string>
  11.  
  12. using namespace std; // USING THE STANDART NAMESPACE
  13.  
  14. int main(){
  15. ifstream fd;
  16. fd.open("Duom2.txt");
  17. int n, v, h, m;
  18.  
  19. fd >> n >> v >> h >> m;
  20. vector<double> s;
  21. vector<string> miestas;
  22. string line;
  23. while (getline(fd,line)) {
  24. if (line.empty()) continue;
  25. istringstream is(line);
  26. string word;
  27. while (is >> word) {
  28. if (isdigit(word[0])) {
  29. int val;
  30. stringstream ss(word);
  31. ss >> val;
  32. s.push_back(val);
  33. } else {
  34. miestas.push_back(word);
  35. }
  36. }
  37.  
  38.  
  39. }
  40. fd.close();
  41.  
  42. double laikas = h * 60 + m;
  43. ofstream fr;
  44. fr.open("Rez2.txt");
  45. for ( int i = 0; i < n; i++ ) {
  46.  
  47. double temp = s.at(i) / v * 60;
  48. laikas = laikas + temp;
  49. double valandos = trunc(laikas / 60);
  50. int temp2 = trunc(laikas);
  51. double minutes = temp2 % 60;
  52.  
  53. fr << left << setw(12) << miestas.at(i) << right << setw(5) << valandos << " val. " << minutes << " min." << endl;
  54.  
  55.  
  56. }
  57. fr.close();
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement