Advertisement
CamolaZ

Untitled

Feb 27th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.    
  8.    
  9.     int c,f;
  10.     int x, y;
  11.     int a, b, d, e;
  12.  
  13.     int det,dx,dy; // Para efeito deste problema
  14.  
  15.     cout << " |a*x + b*y = c \n-\t\t\t, digite a,b,c,d,e,f\n |d*x + e*y = f \n\n";
  16.     cin >> a >> b >> c >> d >> e >> f;
  17.  
  18.     x = (c*e - b*f) / (a*e - b*d);
  19.     y = (a*f - c*d) / (a*e - b*d);
  20.  
  21.     // Cálculo do determinante ... 2 linhas a 2 incógnitas
  22.      
  23.     det = (a * x) * (e*y) - (d*x) * (b*y);
  24.  
  25.     dx = c * (e * y) - f * (b *y);
  26.     dy = (a * x) * f - (d * x) * c;
  27.  
  28.     if (det == 0) //    Caso ser 0 , pode ser indeterm. ou impossivel
  29.  
  30.         if (dx == 0 && dy == 0) // Caso estes forem 0 temos 0x
  31.             cout << "Possível Indeterminado" << endl;
  32.         else
  33.             cout << "Impossível" << endl;
  34.     else
  35.         cout << "\n\nCaso solucao: \n";
  36.     cout << " |x=" << x << endl
  37.          << "- \n"
  38.          << " |y=" << y
  39.          << endl;
  40.     // fiz o programa só que nas situações (restritas a minha funções nos calculos são impedidas) pois dá quociente div 0, o que faço!?.
  41.     cin.clear();
  42.     cin.ignore();
  43.     cin.get();
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement