C 언어 쌉거수님들 이것좀 질문할게요 [44]
2015-03-08 18:22:24 (11년 전) / READ : 4076
0~ 999 난수로 배열 100, 500, 1000 개 만들어서 하려해서 일단 1000개 부터하려고 하고있고요
0부터 순행이랑 역순으로 printf 하려고 합니다 그래서 역순으로 짜본게
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int ary();
int i;
int num=rand();
srand((unsigned)time(NULL));
for(i=0;i<=999;i++)
{
num=rand()%1000;
printf("%d=%dn",999-i,num);
}
return 0;
}
이거고요
순행이
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int ary();
int i;
int num=rand();
srand((unsigned)time(NULL));
for(i=0;i<=999;i++)
{
num=rand()%1000;
printf("%d=%dn",i,num);
}
return 0;
}
이거입니다.
그런데 출력을해보면 순행인경우
701 ~ 999 여기까지나오고
역순은 298 부터 0까지 나옵니다.
두 개다 299줄 밖에 나오지를 않네요.. 왜 그런거죠 ?