Advertisement
Guest User

Untitled

a guest
Mar 7th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <fstream>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. double summa(ifstream file)
  8. {
  9.     int i;
  10.     double input, sum = 0;
  11.     for (i = 0; !file.eof(); ++i) {
  12.         file >> input;
  13.         sum += input;
  14.         cout << input << endl;
  15.     }
  16.  
  17.     return sum;
  18. }
  19.  
  20. int main()
  21. {
  22.     string path;
  23.     getline(cin, path);
  24.     int i;
  25.     for (i = 0; path[i]!='\0'; ++i) {
  26.         if (path[i] == '\\') {
  27.             path[i]= '/' ;
  28.         }
  29.     }
  30.     cout << path << endl;
  31.     ifstream file;
  32.     file.open(path);
  33.     double value = summa(file);
  34.     file.close();
  35.     cout << value << endl;
  36.  
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement