가위바위보 질문드려요
초코우유
질문 제목 : 질문 내용 :
일단 입력함수에서 scanf에서 오류나고요
unsigned short int로 한건데 뭐 int로 바꾸라 이런말은 하지마시고
%d랑 %u 둘다안됩니다..
fflush랑 getchar 있는곳은 안보여주고 바로넘어가버리니까 출력되는거 보려고 넣은거고요
메인함수
#include stdio.h.
#include whowingame.h
int main(int argc, char* argv[]) {
ushort usrrsp, comrsp;
results result=draw;
while(result!=win && result!=lose) {
usrrsp = inputrsp();
comrsp = inputcomrsp();
result = whowingame(usrrsp, comrsp);
}
showresult(result);
return 0;
}
--------------------
유저 입력함수
#include stdio.h
#include stdlib.h
#include whowingame.h
ushort inputrsp() {
ushort usrrsp;
system(cls);
printf(\n\n);
printf(\t---------------------------------------------------------------------\t \n);
printf(\t\t가위바위보 게임에 오신걸 환영합니다! 기회는 단한번입니다~ \n);
printf(\t\t간단히 설명을하자면 가위는1 바위는2 보는3 이라고요! \n);
printf(\t\t자아~ 간다!★☆★☆★☆★☆★☆★ \n);
scanf(%u, &usrrsp);
return usrrsp;
}
-------------
컴퓨터입력함수
#include stdio.h
#include stdlib.h
#include time.h
#include whowingame.h
ushort inputcomrsp() {
ushort comrsp;
srand((unsigned int)time(null));
printf(\n);
printf(\t---------------------------------------------------------------------\t \n);
printf(\t\t 컴퓨터도 냈습니다~ \n);
comrsp = rand()%3;
comrsp++;
printf(컴터:%d \n, comrsp);
fflush(stdin);
getchar();
return comrsp;
}
-----------
누가이겼는지
#include stdio.h
#include whowingame.h
results whowingame(ushort usrrsp, ushort comrsp) {
results result;
fflush(stdin);
if(usrrsp == comrsp) {
printf(비김 \n);
getchar();
return draw;
}
else if(usrrsp comrsp) {
printf(이김 \n);
getchar();
return win;
}
else if(usrrsp comrsp) {
printf(짐 \n);
getchar();
return lose;
}
else {
printf(에러 \n);
getchar();
return error;
}}
-----
출력
#include stdio.h
#include stdlib.h
#include whowingame.h
void showresult(results result) {
system(cls);
printf(\n\n);
printf(\t결과는!! ★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆\n);
printf(\t\t아무 문자나 누르시면 뜹니다 하하 \n);
getchar();
switch(result) {
case win:
printf(\t\t이기셨습니다! \n);break;
case lose:
printf(\t\t지셨습니다! \n);break;
default:break;
}
}
헤더파일
#define ushort unsigned short int
typedef enum _boolean{false=0, true=1}boolean;
typedef enum gane_results{win=2, lose=1, draw=0, error=-1}results;
ushort inputrsp();
ushort inputcomrsp();
results whowingame(ushort usrrsp, ushort comrsp);
void showresult(ushort);
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2695327 | 안녕하세요 제가 이번에 좀 큰 프로그램을.. | 악당 | 2025-05-19 |
2695295 | mutex동기화의 thread기반 채팅 서버소스 질문입니다 | 그루터기 | 2025-05-19 |
2695270 | 질문이요..swap 관한겁니다..ㅠㅠ (3) | 콩알녀 | 2025-05-19 |
2695244 | 노땅초보궁금한게 하나 있는데요..반복문(while문)초보자질문 (6) | 큰꽃늘 | 2025-05-18 |
2695166 | do while 문 어떤것이잘못된건지 모르겠어요 (2) | 아이폰 | 2025-05-18 |
2695122 | 구조체에 대해 물어보고 싶은게 있습니다 ^^^.. (7) | 수련 | 2025-05-17 |
2695091 | txt 파일 입출력 후 2차 배열에 저장하기입니다. (3) | 헛장사 | 2025-05-17 |
2695063 | 수도요금 프로그램좀 짜주세요. | 시내 | 2025-05-17 |
2695033 | 답변좀요ㅠㅠ (1) | 비사벌 | 2025-05-16 |
2695010 | C++의 STL은 왜 굳이 템플릿화 시켜서 라이브러리를 만드나요? (초보수준의 질문..) (2) | 엘보어 | 2025-05-16 |
2694958 | 로직이 변한다는 것에 대해서 궁금합니다. | 튼동 | 2025-05-16 |
2694929 | 열혈강의 25-2 두번째 문제 질문 | 지우개 | 2025-05-15 |
2694900 | dequeue 에서 리턴값 프린트 방법알려주세요 오늘 12시까지 대화방에 있습니다 도와주세요 | 미투리 | 2025-05-15 |
2694854 | 절대값을 구할때 (2) | 그녀는귀여웠다 | 2025-05-15 |
2694827 | 이제 어떻게 공부해야할지 모르겠네요 | 새얀 | 2025-05-14 |
2694778 | 순열 계산요. | 맛조이 | 2025-05-14 |
2694754 | ShowWindow 함수를 이용하려 하는데 질문있습니다. (2) | 파도 | 2025-05-14 |
2694731 | 리눅스 커널의 시작점 질문 | 미르 | 2025-05-13 |
2694702 | 이거 뭐가문제인가요 코드수정좀 (3) | 맑은 | 2025-05-13 |
2694675 | C언어 후위표기를 중위표기로 | 앨런 | 2025-05-13 |