이벤트 프로그램 제작 초기

By @kimdy7/8/2017kr
#include <stdio.h> //입출력에 필요한 헤더파일 
#include <time.h> //랜덤함수에서 srand에서 time(NULL)을 쓸때 사용 
#include <stdlib.h> //랜덤함수를 위한 헤더파일 
#include <windows.h> //GetStdHandle,gotoxy등 콘솔화면을 제어할떄 쓰는 헤더파일 
#define col GetStdHandle(STD_OUTPUT_HANDLE) //색깔을 쓸때 정의해주는 함수 
#define RED SetConsoleTextAttribute( col,0x000c ); //빨간색
#define BLUE SetConsoleTextAttribute( col,0x0001 | 0x0008); //파란색
#define HIGH SetConsoleTextAttribute( col,0x00a); // 연두
#define WHITE SetConsoleTextAttribute( col,0x000f); // 흰색
#define SKY SetConsoleTextAttribute( col, 0x000b); //하늘색
#define YEL SetConsoleTextAttribute( col, 0x000e); //노란색
#define HIG SetConsoleTextAttribute( col, 0x000d); //연보라 
#define VIO SetConsoleTextAttribute( col,0x0001 | 0x0008 |0x000c); //보라
#define BCK SetConsoleTextAttribute( col,0x0000); // 검은색
#define GRAY SetConsoleTextAttribute( col,0x0008); // 회색
#define WHT SetConsoleTextAttribute( col,0x000F); // 하얀색
#define RRD SetConsoleTextAttribute( col,0x0004); // 피색
#define GREEN SetConsoleTextAttribute( col,0x0002); // 녹색
int rand_num; //rand_num이라는 변수를 전역변수로 사용 
void source()//랜덤으로 숫자를 뽑는 소스 
{
	int num;	
	HIG; //연보라색으로 지정 
	printf("참가자의 수를 정하시오 : ");
	scanf("%d",&num);
	srand((unsigned)time(NULL));//그냥 랜덤함수를 쓰면 첫번째 숫자만 나오므로 srand를 써야한다. 
	for(int i=0; i<3; i++){//당첨자가 3명이므로 3번 반복 
		rand_num = rand()%num+1;//랜덤함수 여기서 1은 첫시작이로 num은 1~num까지 범위로 지정해줌 
		printf("\n당첨번호 : %d",rand_num);
	}
} 
int main()
{
	source();//소스 함수 불러오기 
}

현재까지는 랜덤으로 숫자만 불러오고 디자인을 위한 색만 집어 넣었고, 이제 2차원 배열로 숫자를 크게 만들고 프로그램을 실행 시키면서 숫자가 중복되지 않게 만들 예정.
이벤트 글 링크 : https://steemit.com/kr/@kimdy/2r58dr
기간 2017-07-13(목)

3

comments