天天看點

c語言程式隻執行一次,請問大家,為什麼我調用我定義的函數倆次,但是程式隻執行一次...

該樓層疑似違規已被系統折疊 隐藏此樓檢視此樓

#include

#include

#include

void gotoxy(int y,int x)

{

COORD scrn;

HANDLE hOuput=GetStdHandle(STD_OUTPUT_HANDLE);

scrn.X=x;scrn.Y=y;

SetConsoleCursorPosition(hOuput,scrn);

}

void put(int n,char ch)

{

for(int i=0;i

printf("%c",ch);

}

int height=20;int width=60;

void face()

{

gotoxy(5,5);

put(width,'*');

for(int j=0;j

{

gotoxy(6+j,5);

printf("*");

}

gotoxy((height+5),5);

put(width,'*');

for(int n=0;n

{

gotoxy(6+n,width+4);

printf("*\n");

}

}

void ball(int x,int y,int xp,int yp)

{

while(1)

{

gotoxy(y,x);

printf("o");

Sleep(200);

gotoxy(y,x);

printf(" ");

x+=xp;

y+=yp;

if(x>width+2||x<7)

xp=-xp;

if(y>height+3||y<7)

yp=-yp;

if(x>=width+2)

x=width+2;

if(y>height+4)

y=height+4;

if(x<=7)

x=7;

if(y<6)

y=6;

}

}

main()

{

face();

ball(8,13,2,3);

ball(12,10,4,1);

}