求助大佬 这个输出是什么原因呢??/
程序代码:
#include<stdio.h> #include<stdlib.h>//system #include<windows.h>//sleep #include<conio.h>//kbhit getch void HideCursor() { CONSOLE_CURSOR_INFO cursor_info={1,0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info); } int main() { int i,j,position_width,position_height; int bullet_x,bullet_y; int enemy_x,enemy_y; int width,height; int d,enemy_xx; enemy_xx=1; int speed=0; char input; d=0; width=33; height=20; position_width=width/2; position_height=height/2; enemy_x=position_width-1; enemy_y=position_height-1; bullet_x=0; bullet_y=0; while(1) { HideCursor(); system("cls"); for(i=0;i<height;i++) {for(j=0;j<width;j++) { if((i==position_height)&&(j==position_width)) printf("*"); if((i==bullet_y)&&(j==bullet_x)) { printf("|"); } if((i==00)&&(j==29)) printf("得分=%d",d); if((i==enemy_y)&&(j==enemy_x)) printf("@"); else printf(" "); } printf("\n"); } if(speed<10) speed++; if(speed==2) { enemy_x=enemy_x+enemy_xx; speed=0; } if((enemy_y==bullet_y)&&(enemy_x==bullet_x)) { d=d+1; enemy_y=rand()%19; enemy_x=rand()%32; } if(bullet_y>-1) bullet_y--; if(width==position_width) position_width=width-1; if(height==position_height) position_height=height-1; if((enemy_x>width)||(enemy_x<0)) enemy_xx=-enemy_xx; if(kbhit()) { input=getch(); if(input=='a') position_width--; if(input=='d') position_width++; if(input=='w') position_height--; if(input=='s') position_height++; if(input=='j') { bullet_x=position_width; bullet_y=position_height-1; } } if((enemy_x==position_width)&&(enemy_y==position_height)) { break; } } system("cls"); printf("game over"); }