구조체 질문....
사에
구조체를 이용한 콘솔창화면 위쪽에서 아래로 별이 랜덤하게 떨어지는 프로그램 인데요...
아래의 빨간색 글씨로 표시된 부분이 잘 이해가 안가서요... 무엇을 의미하는지 알려주셨으면 합니다..#include c:\myheader.h
#define MAX 30 // 전처리기 MAX를 30으로 치환
// 구조체 정의 star자료형
struct star
{
int x;// 맴버변수 x좌표
int y;// 맴버변수 y좌표
int sp;// 멤버변수 속도
int place;// 멤버변수 sp를 place에 넣을 변수
};
int main()
{
struct star st[MAX];// 구조체 선언 , 구조체형 배열 st를 선언하되 MAX크기만큼 해라
int i;// 반복문 변수
// 랜덤값
srand(time(NULL));
rand(); rand(); rand();
srand(rand());
// 별의 초기값 부여 loop
for(i=0;iMAX;i++)
{
do
{
st[i].x = rand()%71; // 0 ~ 70 까지, 별의 x 초기값
}while(st[i].x %2 != 0); // ????????????
st[i].sp = rand()%21;// 떨어지는 속도
st[i].place = st[i].sp;
st[i].y = rand()%3; // 0 ~ 2 까지, 별의 y 초기값
gotoxy(st[i].x,st[i].y); // x y 좌표 이동
printf(☆);// 출력
}
while(1)
{
// 별 떨어뜨리기 loop
for(i=0;iMAX;i++)
{
if(--st[i].sp == 0 )// 스피드 구문
{
gotoxy(st[i].x,st[i].y);// 이전 별 좌표로 이동
printf( );// 이전 별 지우기
st[i].y++;// y좌표 1씩 증가
gotoxy(st[i].x,st[i].y);
printf(☆);
// y좌표가 20일 때 별을 백업 loop
if(st[i].y == 20)
{
gotoxy(st[i].x,st[i].y);// 좌표 이동
printf( );// 별 지우기
st[i].sp = rand()%21;
st[i].x = rand()%71;// x좌표 랜덤
st[i].y = 0;// y좌표 0 초기값
gotoxy(st[i].x,st[i].y);
printf(☆);
}
st[i].sp = st[i].place;
}
}
Sleep(50);
}return 0;
}