#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void main(void)
{
srand((int)time(NULL));
short a=0;
short b=0,c=0,d=0;
while(a<100)
{
short num;
num = rand()%3;
if(num==0)
{
printf("고양이 \n");
b++;
}
else if(num==1)
{
printf("강아지 \n");
c++;
}
else
{
printf("돼지 \n");
d++;
}
a++;
}
printf("고양이 %d마리 \n",b);
printf("강아지 %d마리 \n",c);
printf("돼지 %d마리 \n",d);
}
error C2143: syntax error : missing ';' before 'type'
별루 문제 되는게 없다고 생각 하는데 에러가 뜨네요..
맥 OS라
test.c: In function ‘main’:
test.c:5: warning: return type of ‘main’ is not ‘int’
요런 경고 난거 외엔 별 문제없이 잘 돌아갑니다.
실행해보면
강아지
....
고양이 35마리
강아지 26마리
돼지 39마리
이렇게 나오네요. 컴파일러가 이상한걸지도..?