// asd.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int _tmain(int argc, _TCHAR* argv[])
{
int i, mycount, comcount,count=0; //카운터 변수가 햇갈려서 1개로 햇어요
do
{
printf("몇개의 숫자를 부르시겠습니까?\n");
printf("1에서 3사이의 숫자를 입력하세요.\n");
scanf("%d", &mycount);
if (1<=mycount && mycount<=3)
{
printf("당신이 부른 숫자는 : ");
for(i=1; i<=mycount; i++)//for문은 알아보기 쉽게 1부터 카운트까지로 하고
{
++count;//카운터가 증가후
printf("%d ", count);//카운터 출력
if (count==31) break;//판단
}
if (count==31) //포문 빠져나오자마자 출력후 do와일문 탈출
{printf("당신이 패배하셨습니다.\n"); break;}
else printf("\n");
srand(time(NULL));
comcount = rand()%3+1;
printf("컴퓨터가 부른 숫자는 : ");
for(i=1; i<=comcount; i++)
{
++count;
printf("%d ", count);
if (count==31) break;
}
if (count==31)
{printf("당신이 승리하셨습니다.\n");break;}
else printf("\n");
}
else
{
printf("다시 입력하세요.\n");
}
}
while (count<31);
//if((com+i)>=31)
// printf("당신이 승리하셨습니다.\n");
// else
// printf("당신이 패배하셨습니다.\n");
return 0;
}
출처:http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=
1040101&docId=112971791&qb=Y+yWuOyWtCDqsozsnoTrp4zrk6TquLA=
&enc=utf8§ion=kin&rank=15&search_sort=0&spq=0
'프로그래밍 > c언어' 카테고리의 다른 글
ASCII코드 (0) | 2010.11.13 |
---|---|
gotoxy 함수 정의 (0) | 2010.11.12 |
연산자 (0) | 2010.10.13 |
기본적 사용법 (0) | 2010.10.13 |
라이브러리/헤더파일 (0) | 2010.09.29 |