跳过程序语句
大佬们,为什么我这个程序在输入第一组数据后回车,程序就结束了?就是只执行到getchar前面的那个程序,实在是看不出哪里有问题。开关语句里还有点小问题还没改,不劳大佬查看了。#include <stdio.h>
#include <stdlib.h>
int main()
{
{ double rate,capital;
float deposit;
int year;
char a;
printf("Input rate, year, capital:");
scanf("%lf,%d,%lf",&rate,&year,&capital);
getchar();
printf("Compound interest (Y/N)?" );
scanf(" %c",&a);
switch(a){
case 'Y':
printf("deposit = %.4f\n",deposit=capital*pow(1+rate,year));
break;
case 'N':deposit=capital*(1+rate*year);
printf("deposit = %.4f\n",deposit=capital*(1+rate*year));
break;}
return 0;
}
return 0;
}