#include <bits/stdc++.h> using namespace std; int main() { int h=8,l=8,a_h,a_l,b_h,b_l; char qi,zhi; cin>>a_h>>a_l>>b_h>>b_l; while(1){ for(int i=1;i<h;i++){ for(int j=1;j<l;j++) { if(i==a_h&&j==a_l) { cout<<setw(4)<<"*"; }else if(i==b_h&&j==b_l){ cout<<setw(4)<<"%"; }else{ cout<<setw(4)<<"+"; } } cout<<endl; } cout<<"输入awsd"<<endl; cin>>qi; if(qi=='A'||qi=='a') { a_l--; if(a_l<1) { a_l=1; } if(b_l==a_l&&b_h==a_h) { b_l--; } }else if(qi=='d'||qi=='D') { a_l++; if(a_l>l) { a_l=l; } if(b_l==a_l&&b_h==a_h) { b_l++; } }else if(qi=='w'||qi=='W') { a_h--; if(a_h<1) { a_h=1; } if(b_l==a_l&&b_h==a_h) { b_h--; } }else if(qi=='s'||qi=='S') { a_h++; if(a_h>h) { a_h=h; } if(b_l==a_l&&b_h==a_h) { b_h++; } }else{ cout<<"你尽搁着瞎胡按"; return 0; } system("cls"); } return 0; }
标签:int,++,else,--,&&,旗子,qi From: https://www.cnblogs.com/hanxuyao/p/17615318.html