⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prac48.cpp

📁 this program is good for C++ learner
💻 CPP
字号:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<iostream.h>
#include<alloc.h>
class R1{
  public:
   float a,b,c,del;
      //int *m;
   R1(){
   a=c=1;
   b=2;
   }

   R1(float a1){
   a=a1;
   b=2;
   c=1;
   }

  R1(float a1,float b1){
   a=a1;
   b=b1;
   c=1;
   }

  R1(float a1,float b1,float c1){
   a=a1;
   b=b1;
   c=c1;
   }

   float delta(float a,float b,float c){
     del= (pow(b,2)-(4*a*c));
   }


};

class EQ:public R1{

 public:
   float x1,x2;

   void read(){
     cin>>a>>b>>c;
   }

   EQ():R1(){}
   EQ(float a):R1(a){}
   EQ(float a,float b):R1(a,b){}
   EQ(float a,float b,float c):R1(a,b,c){}

   void root(){
     delta( a,b,c);
     if (del>=0){
       x1= ((-b)+sqrt(del))/(2*a);
       x2= ((-b)-sqrt(del))/(2*a);
       cout<<"x1 = "<<x1<<"\n"<<"x2 = "<<x2;
     }
     if (del<0)
       cout<<"no real roots!";
   }
};
void main(){
  EQ eq;
  eq.read();
  eq.root();
  getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -