U E D R , A S I H C RSS

새싹교실/2016/탈레반/0328 (rev. 1.20)

새싹교실/2016/탈레반/0328

참여자

강사 반페이지 학생
장우진탈레반김소연서현수민
O O O

진행

  • 장소 : 6층 피씨실
  • 시간 : 5 : 00 ~ 7 : 00

진행상황

  • scanf 보충설명 - 버퍼, getchar(), scanf_s()에 대해서
  • 연산자
  • 조건문
  • 반복문

과제

  • 1. 가위바위보 게임을 만들자 - (필수)
  • 2. 컴퓨터가 생각한 수를 맞춰보자 - (해오면 음료)

김소연

1. 가위바위보
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int you, s, com;
	int win, lose, same;
	win = 0;
	lose = 0;
	same = 0;

	printf("가위 바위 보를 선택하세요. (가위:1, 바위:2, 보:3) : ");
	scanf("%d", &you);

	while (you == 1 || 2 || 3) {
		if (you == 1) {
			printf("가위를 내셨습니다.\n");

			s = rand();
			com = s % 4;

			while (com == 0) {
				s = rand();
				com = s % 4;
			}

			if (com == 1) {
				printf("컴퓨터는 가위를 냈습니다.\n");
				printf("비겼습니다.\n");
				same++;
				printf("%d승 %d패 %d무\n\n", win, lose, same);
				printf("20165417 김소연\n\n");
			}

			else if (com == 2) {
				printf("컴퓨터는 바위를 냈습니다.\n");
				printf("컴퓨터가 이겼습니다.\n");
				lose++;
				printf("%d승 %d패 %d무\n\n", win, lose, same);
				printf("20165417 김소연\n\n");
			}

			else if (com == 3) {
				printf("컴퓨터는 보를 냈습니다.\n");
				printf("당신이 이겼습니다.\n");
				win++;
				printf("%d승 %d패 %d무\n\n", win, lose, same);
				printf("20165417 김소연\n\n");
			}
		}

		else if (you == 2) {
			printf("바위를 내셨습니다.\n");

			s = rand();
			com = s % 4;

			while (com == 0) {
				s = rand();
				com = s % 4;
			}

			if (com == 1) {
				printf("컴퓨터는 가위를 냈습니다.\n");
				printf("당신이 이겼습니다.\n");
				win++;
				printf("%d승 %d패 %d무\n\n", win, lose, same);
				printf("20165417 김소연\n\n");
			}

			else if (com == 2) {
				printf("컴퓨터는 바위를 냈습니다.\n");
				printf("비겼습니다.\n");
				same++;
				printf("%d승 %d패 %d무\n\n", win, lose, same);
				printf("20165417 김소연\n\n");
			}

			else if (com == 3) {
				printf("컴퓨터는 보를 냈습니다.\n");
				printf("컴퓨터가 이겼습니다.\n");
				lose++;
				printf("%d승 %d패 %d무\n\n", win, lose, same);
				printf("20165417 김소연\n\n");
			}
		}

		else if (you == 3) {
			printf("보를 내셨습니다.\n");

			s = rand();
			com = s % 4;

			while (com == 0) {
				s = rand();
				com = s % 4;
			}

			if (com == 1) {
				printf("컴퓨터는 가위를 냈습니다.\n");
				printf("컴퓨터가 이겼습니다.\n");
				lose++;
				printf("%d승 %d패 %d무\n\n", win, lose, same);
				printf("20165417 김소연\n\n");
			}

			else if (com == 2) {
				printf("컴퓨터는 바위를 냈습니다.\n");
				printf("당신이 이겼습니다.\n");
				win++;
				printf("%d승 %d패 %d무\n\n", win, lose, same);
				printf("20165417 김소연\n\n");
			}

			else if (com == 3) {
				printf("컴퓨터는 보를 냈습니다.\n");
				printf("비겼습니다.\n");
				same++;
				printf("%d승 %d패 %d무\n\n", win, lose, same);
				printf("20165417 김소연\n\n");
			}
		}

		printf("가위 바위 보를 선택하세요. (가위:1, 바위:2, 보:3) : ");
		scanf("%d", &you);
	}

	return 0;
}
  • 너무 자연스러워서 눈치 못챘는데 잘못된 부분이 하나 있네ㅋㅋ 다음 시간에 알려줄께 - 장우진
2. 생각한 수

박서현

1. 가위바위보


2. 생각한 수

허수민

1. 가위바위보


2. 생각한 수


후기

  • 사진은 잘 쓰도록 하겠습니다. - 박인서
    - 소연이가 본인만 얼굴이 나왔다고 시무룩해하던데 - 장우진


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:04
Processing time 0.0265 sec