Advertisement
RenatoLopes

Bhaskara

Oct 1st, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10.  
  11.                         int a;
  12.                         int b;
  13.                         int c;
  14.  
  15.  
  16.     cout << "Especifique a \n";
  17.     cin >> a;
  18.  
  19.     cout << "Especifique b \n";
  20.     cin >> b;
  21.  
  22.     cout << "Especifique c \n";
  23.     cin >> c;
  24.  
  25.     int bSUM = b * b;
  26.     int acMULT = -4 * a * c;
  27.     int abcSUM = bSUM + acMULT;
  28.  
  29.  
  30. cout << "Discriminante: " << abcSUM << endl;
  31.  
  32.  
  33.  
  34. //Resultado 1
  35.     int RaizR;
  36.     int Twoa;
  37.     int NoB;
  38.  
  39.     int resUMsum;
  40.     int resUMdiv;
  41.  
  42.     RaizR = sqrt(abcSUM);
  43.     Twoa = 2 * a;
  44.     NoB = -1 * b;
  45.  
  46.     resUMsum = NoB + RaizR;
  47.     resUMdiv = resUMsum / Twoa;
  48.  
  49.     cout << "Resultado 1: " << resUMdiv << endl;
  50.  
  51. //Resultado 2
  52.     int RaizRd;
  53.     int Twoad;
  54.     int NoBd;
  55.  
  56.     int resUMsumd;
  57.     int resUMdivd;
  58.  
  59.     RaizRd = sqrt(abcSUM);
  60.     Twoad = 2 * a;
  61.     NoBd = -1 * b;
  62.  
  63.     resUMsumd = NoBd + RaizRd;
  64.     resUMdivd = resUMsumd / Twoad;
  65.  
  66.     cout << "Resultado 2: " << resUMdivd << endl;
  67.  
  68.     cout << "Créditos Renato Lopes (steam: id/RenatoBeSt) Dev-hg.net e infoescola.com";
  69.  
  70.  
  71.  
  72.  
  73. // Managed to accomplish this on 5 tutorials!
  74. // Consegui isso em 5 tutoriais!
  75.  
  76. // thx http://www.dev-hq.net/c++/3--mathematical-operators &
  77. // http://www.infoescola.com/matematica/formula-de-bhaskara/
  78.  
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement