Dvortsov_D1

сделанная программа для шара без отскока ктрактория \

Dec 15th, 2017
79
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.  
  8.  
  9. int main()
  10. {
  11.     float x,y,Vx,Vy,dt;
  12.     float g=9.8;
  13.  
  14.     string inpath="/home/user/text_in.txt";
  15.     ifstream infile(inpath.c_str());
  16.     string line;
  17.     getline(infile,line);
  18.     cout << line << endl;
  19.     istringstream iny(line);
  20.     iny>>x>>y>>Vx>>Vy>>dt;
  21.     string outpath="/home/user/text_out.txt";
  22.     cout << x << "\t" << y << "\t" << Vx << "\t" << Vy << endl;
  23.     ofstream outfile;
  24.     outfile.open(outpath.c_str());
  25.     while(y>0){
  26.         x=x+Vx*dt;
  27.         y=y+Vy*dt;
  28.         outfile <<x<<"   "<<y<< endl;
  29.         Vy-=g*dt;
  30.  
  31.     }
  32.     outfile.close();
  33.     infile.close();
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment