ถ้าเราอยากเติมสกอร์นับเเต้มด้วยควรทำยังไงคะ
#include<stdio.h>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
main()
{
int a=0,com=0;
printf("Rock = 1\n");
printf("Scissors = 2\n");
printf("Paper = 3\n");
printf("Input 0 to Exit\n\n");
printf("Input 1-3 or 0 = ");
scanf("%d",&a);
while(a!=0)
{
srand(time(NULL));
com = (rand() %3+1);
if(a>0&&a<=3)
{
switch(a){
case 1 : if(com==1)
{
printf("Rock ",a);
printf("Equal");
printf(" Rock(bot)\n",com);
}
else if(com==2)
{
printf("Rock ",a);
printf("Win");
printf(" Scissors(bot)\n",com);
}
else
{
printf("Rock ",a);
printf("Lose");
printf(" Paper(bot)\n",com);
}
break;
case 2 : if(com==2)
{
printf("Scissors ",a);
printf("Equal");
printf(" Scissors(bot)\n",com);
}
else if(com==3)
{
printf("Scissors ",a);
printf("Win");
printf(" Paper(bot)\n",com);
}
else
{
printf("Scissors ",a);
printf("Lose");
printf(" Rock(bot)\n",com);
}
break;
case 3 : if(com==3)
{
printf("Paper ",a);
printf("Equal");
printf(" Paper(bot)\n",com);
}
else if(com==1)
{
printf("Paper ",a);
printf("Win");
printf(" Rock(bot)\n",com);
}
else
{
printf("Paper ",a);
printf("Lose");
printf(" Scissors(bot)\n",com);
}
break;}
}
else
{
printf("again \n");
}
printf("Input 1-3 or 0 = ");
scanf("%d",&a);
}
printf("Thank you\n");
getch();
}
เติมสกอร์โรเเกรมยังไงคะ
#include<stdio.h>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
main()
{
int a=0,com=0;
printf("Rock = 1\n");
printf("Scissors = 2\n");
printf("Paper = 3\n");
printf("Input 0 to Exit\n\n");
printf("Input 1-3 or 0 = ");
scanf("%d",&a);
while(a!=0)
{
srand(time(NULL));
com = (rand() %3+1);
if(a>0&&a<=3)
{
switch(a){
case 1 : if(com==1)
{
printf("Rock ",a);
printf("Equal");
printf(" Rock(bot)\n",com);
}
else if(com==2)
{
printf("Rock ",a);
printf("Win");
printf(" Scissors(bot)\n",com);
}
else
{
printf("Rock ",a);
printf("Lose");
printf(" Paper(bot)\n",com);
}
break;
case 2 : if(com==2)
{
printf("Scissors ",a);
printf("Equal");
printf(" Scissors(bot)\n",com);
}
else if(com==3)
{
printf("Scissors ",a);
printf("Win");
printf(" Paper(bot)\n",com);
}
else
{
printf("Scissors ",a);
printf("Lose");
printf(" Rock(bot)\n",com);
}
break;
case 3 : if(com==3)
{
printf("Paper ",a);
printf("Equal");
printf(" Paper(bot)\n",com);
}
else if(com==1)
{
printf("Paper ",a);
printf("Win");
printf(" Rock(bot)\n",com);
}
else
{
printf("Paper ",a);
printf("Lose");
printf(" Scissors(bot)\n",com);
}
break;}
}
else
{
printf("again \n");
}
printf("Input 1-3 or 0 = ");
scanf("%d",&a);
}
printf("Thank you\n");
getch();
}