[問題] 為何無法執行第二行 scanf ???
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
linux
問題(Question):
int main (void)
{
double principal;
double rate;
double amount;
int year;
printf("Enter your total principal\n");
scanf("%21.2f", &principal);
printf("Enter your rate\n");
scanf("%f", &rate); →無法讓我執行 輸入第二個變數的動作
printf("%4s%21s\n", "Year", "Amount on deposit");
for(year=1; year <=10; year++){
amount = principal * pow (1.0+rate,year);
printf("%4d%21.2f\n", year, amount);
}
return 0;
}
錯誤結果(Wrong Output):
Enter your total principal
10000
Enter your rate →不給我輸入........ (ˋ_ˊ)
Year Amount on deposit
1 0.00
2 0.00
3 0.00
4 0.00
5 0.00
6 0.00
7 0.00
8 0.00
9 0.00
10 0.00
檢查好幾次了,不知道錯誤在哪邊 @_@
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.34.25.244
→
10/30 12:39, , 1F
10/30 12:39, 1F
→
10/30 12:39, , 2F
10/30 12:39, 2F
→
10/30 12:43, , 3F
10/30 12:43, 3F
→
10/30 12:44, , 4F
10/30 12:44, 4F
→
10/30 12:46, , 5F
10/30 12:46, 5F
→
10/30 15:23, , 6F
10/30 15:23, 6F
→
10/30 16:44, , 7F
10/30 16:44, 7F
→
10/30 18:36, , 8F
10/30 18:36, 8F