只是一個程序在這裏從另一個數字中減去一個數字。我得到-23882489428948248829 ...等差異...你能說出原因嗎?減去功能瘋狂
#include <stdio.h>
double minus(double a, double b) { // set up minus function
double difference = a - b;
return difference;
}
int main() //begin program
{
double a; //declare variables in this scope
double b;
printf("Enter the first number:\n");
scanf_s("%f", &a); //get a from user
printf("Enter the second number:\n");
scanf_s("%f", &b); //get b from user
printf("The difference is %f\n", minus(a,b)); //print results
return 0;
}
在'scanf'中使用''%lf「''雙'' – BLUEPIXY
@BLUEPIXY但是我記得Turbo C的舊日,'%f'對於float和double都可以嗎?但在Visual Studio中,它表現得很奇怪。 –
爲什麼人們沒有評論就冷靜下來? –