【发布时间】:2017-07-27 14:50:31
【问题描述】:
在我的p 和q 中输入值后,我在scanf 中输入值,然后在printf 中输入值。为什么?
void gyllenSnitten(void);
void Andragradare(void);
double p,q;
double root1, root2;
void main()
{
gyllenSnitten();
Andragradare();
}
void gyllenSnitten(void){
printf("Gyllende snittet är %d..\n",(1+sqrt(5))/2)
}
void Andragradare(void){
system("cls");
printf("P-q formeln,\n");
printf("Choice youre P \n");
scanf_s("%1f",&p);
printf("Choice youre Q\n");
printf("%1f", &q);
root1 = (-p / 2) + sqrt(((p / 2)*(p / 2)) + q);
root2 = (-p / 2) - sqrt(((p / 2)*(p / 2)) + q);
printf("Here is the first X = %d",root1);
printf("and the other onehere X = %d",root2);
_getch();
}
【问题讨论】:
-
%1f应该是%lf,%d应该是%f。 -
printf和scanf的文档有什么不清楚的地方? -
更改但仍然无法正常工作,我在调试中查看步骤并在我的“p”上获得类似 &p 0x00c6a140 {labb3e.exe!double p} {5.356796015279e-315#DEN} double 的值跨度>