Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

새싹교실/2016/탈레반/0328: Difference between revisions

From ZeroWiki
imported>kiissy
No edit summary
imported>woojin818
No edit summary
Line 52: Line 52:
  printf("가위 바위 보를 선택하세요. (가위:1, 바위:2, 보:3) : ");
  printf("가위 바위 보를 선택하세요. (가위:1, 바위:2, 보:3) : ");
  scanf("%d", &you);
  scanf("%d", &you);
  while (you = 1 || 2 || 3) {
  while (you == 1 || 2 || 3) {
  if (you = 1) {
  if (you == 1) {
  printf("가위를 내셨습니다.\n");
  printf("가위를 내셨습니다.\n");
   
   
Line 60: Line 60:
  com = s % 4;
  com = s % 4;
   
   
  while (com = 0) {
  while (com == 0) {
  s = rand();
  s = rand();
  com = s % 4;
  com = s % 4;
  }
  }
   
   
  if (com = 1) {
  if (com == 1) {
  printf("컴퓨터는 가위를 냈습니다.\n");
  printf("컴퓨터는 가위를 냈습니다.\n");
  printf("비겼습니다.\n");
  printf("비겼습니다.\n");
  same++;
  same++;
  printf("%d승 %d패 %d무\n", win, lose, same);
  printf("%d승 %d패 %d무\n\n", win, lose, same);
  printf("\n20165417 김소연\n\n");
  printf("20165417 김소연\n\n");
  }
  }
   
   
  else if (com = 2) {
  else if (com == 2) {
  printf("컴퓨터는 바위를 냈습니다.\n");
  printf("컴퓨터는 바위를 냈습니다.\n");
  printf("컴퓨터가 이겼습니다.\n");
  printf("컴퓨터가 이겼습니다.\n");
  lose++;
  lose++;
  printf("%d승 %d패 %d무\n", win, lose, same);
  printf("%d승 %d패 %d무\n\n", win, lose, same);
  printf("\n20165417 김소연\n\n");
  printf("20165417 김소연\n\n");
  }
  }
   
   
  else if (com = 3) {
  else if (com == 3) {
  printf("컴퓨터는 보를 냈습니다.\n");
  printf("컴퓨터는 보를 냈습니다.\n");
  printf("당신이 이겼습니다.\n");
  printf("당신이 이겼습니다.\n");
  win++;
  win++;
  printf("%d승 %d패 %d무\n", win, lose, same);
  printf("%d승 %d패 %d무\n\n", win, lose, same);
  printf("\n20165417 김소연\n\n");
  printf("20165417 김소연\n\n");
  }
  }
  }
  }
   
   
  else if (you = 2) {
  else if (you == 2) {
  printf("바위를 내셨습니다.\n");
  printf("바위를 내셨습니다.\n");
   
   
Line 96: Line 96:
  com = s % 4;
  com = s % 4;
   
   
  while (com = 0) {
  while (com == 0) {
  s = rand();
  s = rand();
  com = s % 4;
  com = s % 4;
  }
  }
   
   
  if (com = 1) {
  if (com == 1) {
  printf("컴퓨터는 가위를 냈습니다.\n");
  printf("컴퓨터는 가위를 냈습니다.\n");
  printf("당신이 이겼습니다.\n");
  printf("당신이 이겼습니다.\n");
  win++;
  win++;
  printf("%d승 %d패 %d무\n", win, lose, same);
  printf("%d승 %d패 %d무\n\n", win, lose, same);
  printf("\n20165417 김소연\n\n");
  printf("20165417 김소연\n\n");
  }
  }
   
   
  else if (com = 2) {
  else if (com == 2) {
  printf("컴퓨터는 바위를 냈습니다.\n");
  printf("컴퓨터는 바위를 냈습니다.\n");
  printf("비겼습니다.\n");
  printf("비겼습니다.\n");
  same++;
  same++;
  printf("%d승 %d패 %d무\n", win, lose, same);
  printf("%d승 %d패 %d무\n\n", win, lose, same);
  printf("\n20165417 김소연\n\n");
  printf("20165417 김소연\n\n");
  }
  }
   
   
  else if (com = 3) {
  else if (com == 3) {
  printf("컴퓨터는 보를 냈습니다.\n");
  printf("컴퓨터는 보를 냈습니다.\n");
  printf("컴퓨터가 이겼습니다.\n");
  printf("컴퓨터가 이겼습니다.\n");
  lose++;
  lose++;
  printf("%d승 %d패 %d무\n", win, lose, same);
  printf("%d승 %d패 %d무\n\n", win, lose, same);
  printf("\n20165417 김소연\n\n");
  printf("20165417 김소연\n\n");
  }
  }
  }
  }
   
   
  else if (you = 3) {
  else if (you == 3) {
  printf("보를 내셨습니다.\n");
  printf("보를 내셨습니다.\n");
   
   
Line 132: Line 132:
  com = s % 4;
  com = s % 4;
   
   
  while (com = 0) {
  while (com == 0) {
  s = rand();
  s = rand();
  com = s % 4;
  com = s % 4;
  }
  }
   
   
  if (com = 1) {
  if (com == 1) {
  printf("컴퓨터는 가위를 냈습니다.\n");
  printf("컴퓨터는 가위를 냈습니다.\n");
  printf("비겼습니다.\n");
  printf("컴퓨터가 이겼습니다.\n");
  same++;
  lose++;
  printf("%d승 %d패 %d무\n", win, lose, same);
  printf("%d승 %d패 %d무\n\n", win, lose, same);
  printf("\n20165417 김소연\n\n");
  printf("20165417 김소연\n\n");
  }
  }
   
   
  else if (com = 2) {
  else if (com == 2) {
  printf("컴퓨터는 바위를 냈습니다.\n");
  printf("컴퓨터는 바위를 냈습니다.\n");
  printf("컴퓨터가 이겼습니다.\n");
  printf("당신이 이겼습니다.\n");
  lose++;
  win++;
  printf("%d승 %d패 %d무\n", win, lose, same);
  printf("%d승 %d패 %d무\n\n", win, lose, same);
  printf("\n20165417 김소연\n\n");
  printf("20165417 김소연\n\n");
  }
  }
   
   
  else if (com = 3) {
  else if (com == 3) {
  printf("컴퓨터는 보를 냈습니다.\n");
  printf("컴퓨터는 보를 냈습니다.\n");
  printf("당신이 이겼습니다.\n");
  printf("비겼습니다.\n");
  win++;
  same++;
  printf("%d승 %d패 %d무\n", win, lose, same);
  printf("%d승 %d패 %d무\n\n", win, lose, same);
  printf("\n20165417 김소연\n\n");
  printf("20165417 김소연\n\n");
  }
  }
  }
  }

Revision as of 15:54, 29 March 2016

참여자

강사 반페이지 학생
장우진 탈레반 김소연 박서현 허수민
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;
}
  1. 생각한 수

박서현

  1. 가위바위보


  1. 생각한 수

허수민

  1. 가위바위보


  1. 생각한 수


후기

  • 사진은 잘 쓰도록 하겠습니다. - 박인서

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