1、
#include <stdio.h>
int main(void)
{
int i;
do
{
puts("please input value of i (0/1/2)");
printf("i = "); scanf("%d", &i);
}
while (i < 0 || i > 2);
switch (i)
{
case 0 : puts("you had choosen stone!"); break;
case 1 : puts("you had choosen scissors!"); break;
case 2 : puts("you had choosen cloth!"); break;
}
return 0;
}
#include <stdio.h>
int main(void)
{
int i;
do
{
puts("please input value of i(0/1/2)");
printf("i = "); scanf("%d", &i);
}
while (!(i >= 0 && i <= 2));
switch (i)
{
case 0 : puts("you had choosen stone!"); break;
case 1 : puts("you had choosen scissors!"); break;
case 2 : puts("you had choosen cloth!"); break;
default : puts("error!"); break;
}
return 0;
}