我無法獲得與用戶輸入一起工作的指數。每次提示用戶添加輸入時,在輸入輸入後,程序立即關閉。處於指數狀態的問題
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
double input = 0;
double exp_val;
printf("Plese enter the exponent to check for convergence:");
scanf("%f", input,"\n");
printf("%f", input);/*Checking to verify the input is entered*/
exp_val = exp(input);
printf("%f", exp_val);
getchar();
}
打印語句是否需要保持%f,因爲它將立即關閉後用戶輸入輸入 – user3259144
printf不需要%lf。看到這個答案:http://stackoverflow.com/questions/210590/why-does-scanf-need-lf-for-doubles-when-printf-is-okay-with-just-f – happydave
@ user3259144檢查代碼(運行結果)由新的鏈接。 – herohuyongtao