這是什麼意思? 我的計劃是這樣的:(注:有誤差的情況下2.前行未來線)DEV C++錯誤:'}'令牌之前的預期聲明
case 1:
{
cout<< "C * H * E * M * I * S * T * R * Y \n\n";
cout<< "1) What is the valence electron configuration of Selenium (Se)?\n\n";
cout<< "\na) 1s2 2s2 2p6 3s2\n\n";
cout<< "\nb) 1s2 2s2 2p2\n\n";
cout<< "\nc)4s2 4p4\n\n";
cout<< "\nd) 1s2 2s2 2p6 3s2 3p6 4s2 3d10 4p6 5s2 4d10 5p5\n\n";
cout<< "Enter your answer:\n";
cin>> answer;
if (answer == 'c')
{
cout<<"Your answer is correct. Please press the enter key to proceed to the next question.\n\n";
}
else
cout<< "The correct answer is C. Please press the enter key to proceed to the next question.\n\n";
getch();
}
getch();
cout<< "2) Which element yields the biggest atomic radius?\n\n";
cout<< "\na) Ca\n\n";
cout<< "\nb) Xe\n\n";
cout<< "\nc) B\n\n";
cout<< "\nd) Cs\n\n";
cout<< "Enter your answer:\n";
cin>> answer;
if (answer == 'd')
{
cout<< "Your answer is correct. Please press the enter key to proceed to the next question.\n\n";
}
else
cout<< "The correct answer is D. Please press the enter key to proceed to the next question.\n\n";
getch();
}
cout<< "3) Name the ionic compound K2 Cr2 O7\n\n";
cout<< "\na) potassium chloride\n\n";
cout<< "\nb) potassium carbonate\n\n";
cout<< "\nc) potassium chromite\n\n";
cout<< "\nd) potassium chromate\n\n";
cout<< "Enter your answer:\n";
cin>> answer;
if (answer == 'd')
{
cout<< "Your answer is correct. Please press the enter key to proceed to the next question.\n\n";
}
else
cout<< "The correct answer is D. Please press the enter key to proceed to the next question.\n\n";
getch();
}
}
case 2:
{
cout<< "G * E * O * M * E * T * R * Y \n\n";
的錯誤,在標題中提到的expected declaration before '}' token
在行在我開頭一段提到。
請重新格式化您的代碼。 – quasiverse 2011-03-12 06:14:50
最有可能意味着你的「{」,「}」不匹配。我建議使用可以理解C語法並突出顯示匹配大括號的編輯器。 – 2011-03-12 06:18:35
這意味着你的代碼是一個龐大的縮進塊。重構。 – 2011-03-12 06:25:13