|
发表于 2018-3-3 13:19:17
|
显示全部楼层
这个是输入里面带\n的运行结果,个人感觉scanf里面写的是什么,在显示屏里面就要输入什么,但是尽量在scanf里面不要出现转义字符
#include <stdio.h>
#include <math.h>
void main()
{
double a,b,c,x1,x2,p,q,disc;
printf("please input a,b,c\n");
scanf("%lf %lf %lf\n",&a,&b,&c);
disc=b*b-4*a*c;
p=-b/(2*a);
q=sqrt(disc)/(2*a);
x1=p+q;
x2=p-q;
printf("x1=%5.2f,x2=%5.2f\n",x1,x2);
}
/***********************************
--------------------------------
please input a,b,c
1 2 1 \n
x1=-1.00,x2=-1.00
请按任意键继续. . .
--------------------------------
************************************/ |
|