Advertisement
Serafim_

Файлы 1

Dec 8th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <fstream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10.     float g = 9.81;
  11.     ifstream infile("/home/user/in.txt");
  12.     string line;
  13.     getline(infile, line);
  14.     istringstream iny(line.c_str());
  15.     float X,Y,Vx,Vy,dt;
  16.     iny >> X >> Y >> Vx >> Vy >> dt;
  17.     infile.close();
  18.     cout << X << "\t" << Y << "\t" << Vx << "\t" << Vy << endl;
  19.     ofstream file;
  20.     file.open ("/home/user/out.txt");
  21.     while (Y>0){
  22.         X = X + Vx*dt;
  23.         Y = Y + Vy*dt;
  24.         cout << X << "\t" << Y << endl;
  25.         file << X <<"\t"<< Y << endl;
  26.         Vy -= g * dt;
  27.     }
  28.     file.close();
  29.     return 0;
  30. }
  31.  
  32.  
  33. //outfile-вывод
  34. //infale-ввод
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement