#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,i;
float capital,rate,deposit;
printf("Input capital,n",capital,n);
scanf("%f%d",&capital,&n);
if(n>0)
{
switch (n)
{
case 8:
deposit=capital+capital*0.0300*n;
printf("deposit=%f\n",deposit);
break;
case 7:
case 6:
case 5:
deposit=capital+capital*0.0288*n;
printf("deposit=%f\n",deposit);
break;
case 4:
case 3:
deposit=capital+capital*0.0270*n;
printf("deposit=%f\n",deposit);
break;
case 2:
deposit=capital+capital*0.0243*n;
printf("deposit=%f\n",deposit);
break;
case 1:
deposit=capital+capital*0.0225*n;
printf("deposit=%f\n",deposit);
break;
case 0:
default:
printf("Input error!\n");
}
}
return 0;
}
知识点:switch break的用法