분류 | 게시판 |
베스트 |
|
유머 |
|
이야기 |
|
이슈 |
|
생활 |
|
취미 |
|
학술 |
|
방송연예 |
|
방송프로그램 |
|
디지털 |
|
스포츠 |
|
야구팀 |
|
게임1 |
|
게임2 |
|
기타 |
|
운영 |
|
임시게시판 |
|
안녕하세용 공대에서 코딩 공부하고있는 학생인데요
프로그래밍 과제를 하다 막혀서 어떻게 할수가 없더라구요
에러가 난 부분을 찾을수가 없어요 ㅠㅠㅠㅠㅠ
좀 도와주세용
여기서부터...
/**
File Trajectory.txt
Date 17 08 2012
Program name: Trajectory
**/
#include <iostream>
#include <cmath>
#include <iomanip>
#define pi 3.14159
#define kc 0.00114
#define m 0.057
#define g 9.8
using namespace std;
int main()
{
int ballstate = 1;
/*
1 = the ball is served
2 = the ball hits the ground before the net
3 = the ball hits the net
4 = the ball goes over the net
5 = the ball hits the ground inside the service box
6 = the ball hits the ground past the service box
*/
double h;
double s;
double a;
double x0;
double vx0;
double vy0;
double v0;
double y0;
double k;
double x;
double y;
double t;
double v;
double vx;
double vy;
cout << "TRAFECTORY\n";
// input values START //
do
{
cout << "Enter height of serve (m):";
cin >> h;
if (h<=0)
{
cout << "ERROR: Height must be greater than zero.\n";
}
}
while (h<=0);
do //input of speed, must be greater than 0, otherwise display error message
{
cout << "Enter speed of serve (m/sec):";
cin >> s;
if (s<=0)
{
cout << "ERROR: Speed must be greater than zero.\n";
}
}
while (s<=0);
do //input of elevation angle, must be between -90 and 90 degrees otherwise display error message
{
cout << "Enter elevation angle of serve (degrees):";
cin >> a;
if (a< -90 || a>90)
{
cout << "ERROR: Angle must be between -90 and +90 degrees.\n";
}
}
while (a< -90 || a>90);
//input values END//
//initial equations start//
x0 = 0;
y0 = h;
v0 = s;
vx0 = s*cos(a*((pi)/180));
vy0 = s*sin(a*((pi)/180));
k = s*kc
//initial equation end//
//initial values output start//
cout << "\nINITIAL VALUES\n";
cout.setf(ios::fixed);
cout.precision(3);
cout <<setprecision(3)<< "x0 ="<<x0<<"\n";
cout <<setprecision(3)<< "y0 ="<<y0<<"\n";
cout <<setprecision(3)<< "s ="<<s<<"\n";
cout <<setprecision(3)<< "a ="<<a<<"\n";
cout <<setprecision(3)<< "vx0 ="<<vx0<<"\n";
cout <<setprecision(3)<< "vy0 ="<<vy0<<"\n";
cout <<setprecision(3)<< "k ="<<k<<"\n";
//initial values output end//
//trajectory equations start//
cout <<setw(44)<<"CALCULATED TRAJECTORY\n";
cout <<setw(3)<<"t";
cout <<setw(11)<<"x";
cout <<setw(12)<<"y";
cout <<setw(13)<<"vx";
cout <<setw(11)<<"vy";
cout <<setw(12)<<"v\n";
for (t=0.00;t<=1.01;t=t+0.01)
{
//equation start//
x=x0+((m/k)*vx0*(1-exp((-k*t)/m));
y=y0-(((m*g)/k)*t)+(m/k)*(vy0+((m*g)/k))*(1-exp((-k*t)/m));
vx=vx0*exp((-k*t)/m);
vy=-((m*g)/k)+(vy0+((m*g)/k))*exp((-k*t)/m);
v=sqrt((pow(vx,2))+(pow(vy,2)));
//equation end//
cout <<setprecision(2)<<t;
cout <<setprecision(3)<<setw(12)<<x;
cout <<setprecision(3)<<setw(12)<<y;
cout <<setprecision(3)<<setw(12)<<vx;
cout <<setprecision(3)<<setw(12)<<vy;
cout <<setprecision(3)<<setw(12)<<v;
cout<<endl;
//ballstate start//
if(ballstate==1&&y<=0&&x<11.887)
{
cout << "ball hit ground before the net at distance"<<x<<endl;
ballstate=2;
}
else if (ballstate==1&&y>0&&x>11.887)
{
cout << "Over the net at height="<<y<<"\n";
ballstate=4;
}
else if (ballstate==1&&y<1&&x>11.887)
{
cout << "Hit the net at height="<<y<<'\n";
ballstate=3;
}
else if (ballstate==4&&y<0)
{
cout << "Hit inside the service box at distance="<<x<<"\n";
ballstate=5;
}
else if (ballstate==4&&y>0&&x>2*11.887)
{
ballstate=6;
cout << "Past the service box at distance="<<x<<"\n";
}
//ballstate end//
}
cout <<"\nEND OF PROGRAM\n";
system("pause");
return 0;
여기까지가 그 코딩한거고요...
(\는 그 / 이거 반대로 되있는거에요)
요걸 비주얼스튜디오에 복붙하면
TRAJECTORY
Enter height of serve (m): 0
ERROR: Height must be greater than zero.
Enter height of serve (m): 2.5
Enter speed of serve (m/sec): 0
ERROR: Speed must be greater than zero.
Enter speed of serve (m/sec): 30
Enter elevation angle of serve (degrees): -90.1
ERROR: Angle must be between -90 and +90 degrees.
Enter elevation angle of serve (degrees): 90.1
ERROR: Angle must be between -90 and +90 degrees.
Enter elevation angle of serve (degrees): 1
INITIAL VALUES
x0 = 0.000
y0 = 2.500
s = 30.000
a = 1.000
vx0 = 29.995
vy0 = 0.524
k = 0.03420
CALCULATED TRAJECTORY
t x y vx vy v
0.00 0.000 2.500 29.995 0.524 30.000
0.01 0.299 2.505 29.816 0.423 29.819
0.02 0.596 2.508 29.638 0.322 29.639
0.03 0.892 2.511 29.460 0.223 29.461
...
0.45 11.829 1.798 22.898 -3.465 23.159
0.46 12.058 1.763 22.761 -3.542 23.035
Over the net at height = 1.763 m
0.47 12.284 1.727 22.625 -3.619 22.912
0.48 12.510 1.690 22.489 -3.695 22.791
0.49 12.734 1.653 22.355 -3.770 22.671
0.50 12.957 1.615 22.221 -3.845 22.551
...
0.80 19.058 0.144 18.561 -5.903 19.477
0.81 19.243 0.084 18.450 -5.965 19.390
0.82 19.427 0.024 18.339 -6.027 19.304
0.83 19.610 -0.036 18.230 -6.089 19.219
Past the service box at distance = 19.610 m
0.84 19.792 -0.098 18.121 -6.150 19.136
0.85 19.972 -0.159 18.012 -6.211 19.053
...
0.98 22.225 -1.017 16.661 -6.970 18.060
0.99 22.391 -1.087 16.561 -7.026 17.990
1.00 22.556 -1.157 16.462 -7.082 17.921
END OF PROGRAM
그 까만 창에 이렇게 나와야 되요
좀 도와주세영 ㅠㅠ
죄송합니다. 댓글 작성은 회원만 가능합니다.