ex0204.cpp
来自「Visual+C+++6[1].0实用教程代码 Visual+C+++6[1]」· C++ 代码 · 共 30 行
CPP
30 行
// ex0204.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream.h>
#include <math.h>
int main(int argc, char* argv[])
{
double a,b,c,delta;
cout<<"依次输入一元二次方程的系数:";
cin>>a>>b>>c;
delta = b*b - 4*a*c;
if(delta<0)
cout << "无解\n";
else
{
if(delta==0) {
double x1=-b/(2*a);
cout << "方程解为:x=" << x1;
}
else {
delta = sqrt(delta);
double x1 = (-b+delta)/(2*a);
double x2 = (-b-delta)/(2*a);
cout << "方程解为:x1 = " << x1 << " ; " << "x2 = " << x2 << endl;
}
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?