Advertisement
MaximPro

Задание 1 (12)

Nov 28th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10.     ifstream  fin( "c:\\input.txt" );
  11.     ofstream  fout( "c:\\output.txt" );
  12.     double a,b,c,d;
  13.     fin >> a >> b >> c;
  14.          d = b*b-4*a*c;
  15.          if (d>0) {
  16.              double x1 = ( -b+sqrt(d)/(2*a) );
  17.              double x2 = (  -b-sqrt(d)/(2*a) );
  18.              fout << x1 << "  " << x2 << endl;
  19.          }
  20.          if (d==0) {
  21.              double x = -b/(2*a);
  22.              fout << x << endl;
  23.               }
  24.            else {
  25.              fout << "No salution " << endl;
  26.               }
  27.     fin.close();
  28.     fout.close();
  29.     system("PAUSE");
  30.     return EXIT_SUCCESS;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement