Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- float x,y,Vx,Vy,dt;
- float g=9.8;
- string inpath="/home/user/text_in.txt";
- ifstream infile(inpath.c_str());
- string line;
- getline(infile,line);
- cout << line << endl;
- istringstream iny(line);
- iny>>x>>y>>Vx>>Vy>>dt;
- string outpath="/home/user/text_out.txt";
- cout << x << "\t" << y << "\t" << Vx << "\t" << Vy << endl;
- ofstream outfile;
- outfile.open(outpath.c_str());
- while(y>0){
- x=x+Vx*dt;
- y=y+Vy*dt;
- outfile <<x<<" "<<y<< endl;
- Vy-=g*dt;
- }
- outfile.close();
- infile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment