Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  IT 최종
Language: C/C++
Code:
#include <stdio.h>

#include <stdlib.h> 

#include <time.h>

 

int main()

{   

    printf("게임을 시작합니다. \n");

    printf("a&b의 연산을 진행하여 c라는 결과가 나온도록 입력하십시오.\n");

    printf("a와 b를 입력하면, 무작위로 생성된 연산자에 의해 연산이 진행됩니다.\n");

    printf("여러분이 입력하신 c가, 무작위로 연산된 값과 같다면 CLEAR, ");

    printf("다르다면 새로운 입력 창이 나타납니다. ");

    printf("제한시간 30초 안에, 무작위로 생성된 연산자가 무엇인지 알아내어,  ");

    printf("정확한 연산 결과를 입력하십시오.");

    printf("시작하려면 1, 나가려면 0을 입력하십시오.");

    

    int start;

    scanf("%d",&start);

    

        if(start==1)

        {

            int i=1, a, b, c=2;
            printf("START!\n");

            int random = 0;

            random = rand()%10; 
            
            while(i!=c)

            {

                printf("a&b=c 안에 들어갈 a, b, c를 ,를 사이에 두고 입력하십시오.\n");

                scanf("%d, %d, %d",&a, &b, &c);

            

                    if(random==0)

                    {

                        i= a^2+b^2;

    

                        printf("%d '&' %d = %d \n", a, b, i);

                        

                         if(i==c)

                         {

                         printf( "성공하셨습니다\n이 연산은 a와 b 각각의 제곱을 더하는 것이었습니다.");

                         }

                    }

                    if(random==1)

                    {

                        i=(a+1)*(b+1);

 

                        printf("%d '&' %d = %d \n", a, b, i);

                        if(i==c)

                        {

                         printf( "성공하셨습니다\n이 연산은 a+1 값과 b+1 의 값을 곱하는 것이었습니다.");

                        }

                    }

                    if(random==2)

                    {

                        i=b+5;

 

                        printf("%d '&' %d = %d \n", a, b, i);

                        if(i==c)

                        {

                         printf( "성공하셨습니다\n이 연산은 b에 5를 더하는 것이었습니다.");

                        }

                    }

                    if(random==3)

                    {

                        i=a*(b%10)+1;

    

                        printf("%d '&' %d = %d \n", a, b, i);

                        if(i==c)

                        {

                         printf( "성공하셨습니다\n이 연산은 b를 10으로 나눈 나머지를 a와 곱하고, 1을 더하는 것이었습니다. \n ");

                        }

                    }

                    if(random==4)

                    {

                        i=a*b+2*a+2*b;

    

                        printf("%d '&' %d = %d \n", a, b, i);

                        if(i==c)

                        {

                         printf( "성공하셨습니다\n이 연산은 a와 b를 곱한 것과, a, b,를 각각 2배하한 값을 더하는 것이었습니다.");

                        }

                    }

                    if(random==5)

                    {

                        i=(a+b+1)^2;

 

                        printf("%d '&' %d = %d \n", a, b, i);

                        if(i==c)

                        {

                         printf( "성공하셨습니다\n이 연산은 a+b+1 값을 제곱한 것이었습니다.");

                        }

                    }

                    if(random==6)

                    {

                        i=a^3+b;

 

                        printf("%d '&' %d = %d \n", a, b, i);

                        if(i==c)

                        {

                         printf( "성공하셨습니다\n이 연산은 a의 세제곱과 b를 더하는 것이었습니다.");

                        }

                    }

                    if(random==7)

                    {

                        i=b/a+b%a;

 

                        printf("%d '&' %d = %d \n", a, b, i);

                        if(i==c)

                        {

                         printf( "성공하셨습니다\n이 연산은 b를 a로 나눈 몫과 나머지를 더하는 것이었습니다.");

                        }

                    }

                    if(random==8)

                    {

                        i=a/b+b/a;

    

                        printf("%d '&' %d = %d \n", a, b, i);

                        if(i==c)

                        {

                         printf( "성공하셨습니다\n이 연산은 a를 b로 나눈 몫과 b를 a로 나눈 몫을 더하는 것이었습니다.");

                        }

                    }

                    if(random==9)                

                    {

                        i=a%b;

 

                        printf("%d '&' %d = %d \n", a, b, i);

                        if(i==c)

                        {

                         printf( "성공하셨습니다\n이 연산은 a를 b로 나눈 나머지를 뜻하는 것이었습니다..");

                        }    

                    }

            }

        }

        if(start==0)

        {

            printf("END");

        }

    return 0;

}
Comments: