The condition of the problem: the body flies at an angle to the horizon, it is necessary to draw a graph and make a graphical interface.

#include <iostream> #include <cmath> #include <windows.h> using namespace std; int main() { SetConsoleCP(1251); SetConsoOutputCP(1251); //константа -ускорение свободного падения и число pi; const double g=9.8; const double pi=3.14; //sag diskretnosti po vremeni; double dt=0.0001; //rabochii peremennii; double v,alipha,T,t,u,x=0,y=0; int n=0; //ввод параметров задачи; cout<<"введите начальную скорость v = "; cin>>v; cout<<"введите угол alipha = " ; cin>>alipha; //перевод градусов в радианы; alipha=alipha*pi/180; T=2*v*sin(alipha)/g; cout<<"введите время t < " <<T<< " ; " ; cin>>t ; //начальная скорость(проекция); x=v*t*cos(alipha); y=v*t*cos(alipha)-g*t*t/2; //вычислим координаты тела; do{ n++; y+=u*dt; x+=v*dt; u-=g*dt; }while((y>0)&&(n*dt<t)); //вывод результатовс учетом конечного времени полёта; cout<<"y = " <<y<< " : "; cout<<(t<sqrt(2*v*sin(alipha)/g)?v*sin(alipha)*tg*t*t/2:0)<<endl; cout<<"x = " <<x<< " : "; cout<<(t<sqrt(2*v*sin(alipha)/g)?v*cos(alipha)*t:v*v*sin(2*alipha)/g)<<endl; system("PAUSE"); return 0; } { //чертим график; while(T<0.001); { T=T-0.001; canvas->moveto (start x ; start y); x=v*t*cos(alipha); y=v*t*cos(alipha)-g*t*t/2; canvas->lineto (x;y); } if T<0.001 ; { T=0; canvas->moveto (start x ; start y); x=0; y=0; canvas->lineto (x;y); } system("PAUSE"); return 0; } 

That's what happened, how can I add?

  • one
    I don’t think that it is possible to add something else))) - Gorets
  • Well, from that solid text - def50
  • one
    to fix, there are special tags - Gorets

1 answer 1

The phrase: "how to add" is not clear. The code you provided is not working.

  1. The code block after the main function is not a function.
  2. The variable canvas is not declared anywhere and that it is unknown.

Actually it is necessary to take the calculated data and display a graph based on them.