A man punches , keyboard entry (1,2,3 Arbitrary integer ) Randomly generated by computer after input 1,2,3 Any integer represents the fist

Computer random punch : rand()%3+1
#include<stdio.h> void guessGame() { int count=0,i=0; char battle;
printf(" The rules of the game are as follows :\n"); printf("1 Represents stone \n"); printf("2 Represents scissors \n"); printf("3 Representation cloth \n");
while(count<5) { battle=getch(); i=rand()%3+1; count++; if(battle=='1')// Man makes a stone {
if(i==1) { printf(" stone vs stone \n"); printf(" it ends in a draw \n"); } else if(i==2) {
printf(" stone vs scissors \n"); printf(" Man wins \n"); } else if(i==3) { printf(" stone vs cloth \n");
printf(" The computer won \n"); } } if(battle=='2')// Man out scissors { if(i==1) { printf(" scissors vs stone \n");
printf(" The computer won \n"); } else if(i==2) { printf(" scissors vs scissors \n"); printf(" it ends in a draw \n"); } else
if(i==3) { printf(" scissors vs cloth \n"); printf(" Man wins \n"); } } if(battle=='3')// Man out of cloth {
if(i==1) { printf(" cloth vs stone \n"); printf(" Man wins \n"); } else if(i==2) {
printf(" cloth vs scissors \n"); printf(" The computer won \n"); } else if(i==3) { printf(" cloth vs cloth \n");
printf(" it ends in a draw \n"); } } } } int main() { guessGame(); return 0; }
result :

The rules of the game are as follows :
1 Represents stone
2 Represents scissors
3 Representation cloth
stone vs cloth
The computer won
scissors vs cloth
Man wins
scissors vs scissors
it ends in a draw
stone vs scissors
Man wins
cloth vs cloth
it ends in a draw

©2019-2020 Toolsou All rights reserved,
【C++ Must see for entry 】C++ from 0 reach 1 Introductory programming axios Interceptor packaging and use Spring Boot Interview must ask : Automatic configuration principle VMware 16 install centos 7 Detailed tutorial C Language data structure - Sequence table delete duplicates V2.0.0 The 12th Blue Bridge Cup c++b Group personal problem solving On sending data from serial port single chip microcomputer to upper computer centos7 install RabbitMqjava Polymorphic array of opencv-python Fourier transform and inverse transform