如下一段代码,非常的简单,写好后就是不能通过编译,提示:
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(18) : error C2046: illegal case
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(23) : error C2046: illegal case
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(28) : error C2046: illegal case
C:\Documents and Settings\Administrator\桌面\Cpp3.cpp(33) : error C2046: illegal case
看了半天头都大了,就是找不到问题出在哪......
#include<stdio.h>
void main()
{
float lxi, benjin, llxi;
int cq;
printf("\n\t请选择存期:");
printf("\n1.存期一年<2.25%年利率>");
printf("\n2.存期二年<2.7%年利率>");
printf("\n3.存期三年<3.24%年利率>");
printf("\n5.存期五年<3.6%年利率>");
scanf("%d",&cq);
switch (cq);
{
case (cq==1) :
printf("\t\t请输入本金:");
scanf("%f",&benjin);
lxi = benjin * llxi * cq;
printf("利息是:%f",lxi);
case (cq==2) :
printf("\t\t请输入本金:");
scanf("%f",&benjin);
lxi = benjin * llxi * cq;
printf("利息是:%f",lxi);
case (cq==3) :
printf("\t\t请输入本金:");
scanf("%f",&benjin);
lxi = benjin * llxi * cq;
printf("利息是:%f",lxi);
case (cq==5) :
printf("\t\t请输入本金:");
scanf("%f",&benjin);
lxi = benjin * llxi * cq;
printf("利息是:%f",lxi);
}
}