switch()后边不要有;
复制你定义的intUserChoice替换掉switch中的(intUserChoice),
int _tmain(int argc, _TCHAR* argv[])
{
int intComputerChoice;
int intUserChoice;
srand(unsigned(time(NULL)));
intComputerChoice = 1 + rand() % 3;
printf("Enter your choice (1—Rock; 2—Paper; 3—Scissors): ");
scanf("%d", &intUserChoice);
printf("My choice: ");
switch (intUserChoice)
{
case 1:
printf("Rock\n"); break;
case 2:
printf("Paper\n"); break;
case 3:
printf("Scissors\n"); break;
default:
printf("error\n");
}
return 0;
}
发现问题了 你的括号是中文输入法的括号()换成英文的()
switch(intUserChoice)
后面不要加分号,如果加了分号的话,表示你的switch已经结束,后面的case找不到对应的switch就会报错。
还有,你的switch(intUserChoice)用的是全角的括号。必须要用半角的。
switch (intUserChoice);//去掉分号,去掉空格,改为switch(intUserChoice)
满意请采纳,若有疑问,请追问