Notice
Recent Posts
Recent Comments
Creative Code
lotto2.c(로또 번호 추첨) 본문
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int lotto[7];
srand(time(NULL));
for (int i = 0; i<7;){
lotto[i] = rand()% 45+1;
int j;
for (j = 0; j<i; j++){
if (lotto[i] == lotto[j]){
break;
}
}
if (j == i){
++i;
}
}
for (int i = 0; i<7; ++i) {
printf("%2d ",lotto[i]);
}
printf("\n");
return 0;
}
'C Programming' 카테고리의 다른 글
scoreGrade4.c(성적따라 학점부여) (1) | 2023.08.03 |
---|---|
lotto3.c(로또번호 추첨-100만번 섞기) (0) | 2023.08.03 |
pointer6.c(void 포인터) (0) | 2023.08.02 |
pointer5.c(함수포인터) (0) | 2023.08.02 |
pointer4.c(이중포인터) (0) | 2023.08.02 |