求解关于暂停黑窗口的疑问,谢谢~
这是一段计算一元二次不等式的代码,问题是每次运行黑窗口都无法正确暂停,system("PAUSE")语句不是最后暂停,而是在输出结果之前暂停,为什么会出现这种情况?感觉有时候好用,遇见switch和if语句就不太好用,不知道其他情况下怎么样。谢谢答疑~#include <iostream.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include<conio.h>
void main()
{
double a,b,c,delta,x1,x2;
a=1;
b=2;
c=1;
//cin>>a>>b>>c;
if (a==0&&b==0)
cout<<"feiyiyuanercifangcheng\n";
else
if (a==0&&b!=0) //bx+c=0
cout<<"gaifangchengweiyiyuanyicifangcheng,jiewei:"<<-c/b<<'\n';
else
{
delta=b*b-4*a*c;
if (delta<0)
cout<<"fangchengwujie\n";
else
if (delta==0)
cout<<"gaifangchengyoulianggexiangdengdeshishujie:"<<-b/(2*a)<<'\n';
else
{
x1=(-b+sqrt(delta))/(2*a);
x2=(-b-sqrt(delta))/(2*a);
cout<<"gaifangchengyoulianggebudengdeshigenjie:"<<x1<<'\t'<<x2<<'\n';
system("PAUSE");
}
}
system("PAUSE");
}