프로그래밍

 3198, 1/160 회원가입  로그인  
   ruw0424
   배스킨라빈슨데;;컴퓨터 렌덤좀요;;

http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=3097 [복사]


#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
#include<time.h>



int swit(int menu1)
{
        int win,lose;
        
        int c = 1 ;
        int        p;
        int a ;
        int        b;
        int som;
        

        srand(time(NULL));
rand();rand();rand();rand();rand();rand();rand();

srand(rand());

som = rand()%32+1;

        switch(menu1)
        {
                while(1)
                {
        case 1:
                printf("<<plaer turn>>");
                printf("press any number %d ~ %d\n",c ,c+2);
                scanf("%d",&a);

                printf("플레이어가 %d를 입력하셧습니다\n",a);
                
                if(a == c  || a == c +1 || a == c+2)
                {
                
                for(p=c; p<a+1; p++){
                printf("%d\n",p);}
                }

                else if (a != c  || a != c + 1 || a != c +2)
                {
                        printf("다시 입력해주세요\n");
                        c = 1;
                        continue;
                }
                
                printf("<<Computer turn>>\n");
                
                a <= som || som <=a+4;
                
                printf("컴퓨터가 %d를 입력하셧습니다\n",som);
                
                for(c=a+1; c<som+1; c++){
                        printf("%d\n",c);}

            if(c>=31)
                {
                        printf("Player Win!!!\n");
                        win++;
                                break;
                }
                if(c>=31)
                {
                        printf("Computer Win T_T\n");
                        lose++;
                                break;
                }

                
                
                
        case 2:
                printf("You win %d times\nYou lose %d times\n",win,lose);

        case 3:
                exit(0);
                break;
                
        }
        return menu1;
}

        #include"C:\test.h"

int main()
{
int menu;//메뉴 선택 버튼
int haha;
        
        printf("〓〓〓Baskin Robbins 31 Game〓〓〓\n\n\n\n");

        while(1)
        {
        printf("press any number you want \n1.Game Start\n2.Game Score \n3.End Game\n\n");
        scanf("%d",&menu);
        haha = swit(menu);

        if (menu != 1 || menu != 2 || menu != 3)
                {
                        printf("다시 입력해주세요\n");

                        continue;
                }
        }
        return 0;


}

  Hit : 4000     Date : 2011/07/18 07:36



    
파란바다 이 코드에 뭔가 문제가 있으신 건가요? 2011/07/19  
rainroad87 srand(time(NULL));
rand();rand();rand();rand();rand();rand();rand();

srand(rand());

??????????????????????????????????????????????????????????????
2011/07/20  
rainroad87 srand(time(NULL)); 2011/07/20  
dkdkfjgh srand(time(NULL));
rand();rand();rand();rand();rand();rand();rand();

srand(rand());

너무 어지럽네요;;

srand((unsigned int)time(NULL));
2011/08/01  
메버리키 컴퓨터가 무조건 이기게 만드는건 어떠세요 ㅎㅎ
컴퓨터가 먼저시작해서 2 출력하고 그다음부턴 (4-사용자 입력값)를 계속 출력해주면 31만드는게임에선 질수가없어요 ㅋㅋ
2011/08/02