Y 是你,M是目标,P是炮弹 每次输入炮击角度,初速度
#include<bits/stdc++.h>
using namespace std;
int n,sa,cnt=8;
char a[1005][1005];
int main(){
srand(time(0));
for(int i=1;i<=20;i++){
for(int j=1;j<=80;j++){
a[i][j]=' ';
}
}
a[5+rand()%15][20+rand()%30]='M';
a[5+rand()%15][20+rand()%30]='M';
a[5+rand()%15][20+rand()%30]='M';
a[5+rand()%15][20+rand()%30]='M';
a[5+rand()%15][20+rand()%30]='M';
a[5+rand()%15][20+rand()%30]='M';
a[5+rand()%15][20+rand()%30]='M';
a[5+rand()%15][20+rand()%30]='M';
while(1){
for(int i=1;i<=20;i++){
for(int j=1;j<=80;j++){
if(i==20 and j==1){
cout<<"Y";
}else{
cout<<a[i][j];
}
}
cout<<endl;
}
cin>>sa;
double ch=1;
cin>>ch;
sa=90-sa;
double x=sin(sa*1.0/360*2*3.1415926);
double y=cos(sa*1.0/360*2*3.1415926);
// y=1.0/x*y;
double x2=20,y2=1;
cout<<x<<" "<<y<<endl;
while(x2<=20 and y2<=80 and 0<=y2 and -20<=x2){
x2-=y;
y2+=x;
y=y-0.098/ch;
for(int i=1;i<=20;i++){
for(int j=1;j<=80;j++){
if(i==20 and j==1){
cout<<"Y";
}else if(i==int(x2) and j==int(y2)){
cout<<"P";
}else{
cout<<a[i][j];
}
}
cout<<endl;
if(a[int(x2)][int(y2)]=='M'){
a[int(x2)][int(y2)]=' ';
cnt--;
}
}
for(int i=1;i<=10000000/sqrt(x*x+y*y);){
i++;
}
//cout<<x2<<" "<<y2<<" "<<x<<" "<<y<<endl;
system("cls");
if(cnt==0){
return 0;
}
}
}
return 0;
}