Created
November 20, 2014 16:45
-
-
Save Lotuashvili/f761dd5a089ea8390684 to your computer and use it in GitHub Desktop.
კვადრატული განტოლება (C++)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// diskriminant | |
// | |
// Created by GWSMaster on 08.10.14. | |
// Copyright (c) 2014 GWSMaster. All rights reserved. | |
// | |
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
int main(int argc, const char * argv[]) { | |
// insert code here... | |
double a,b,c,d,x1,x2; | |
cout << "sheitanet a,b,c\n"; | |
cin >> a >> b >> c; | |
d = b*b - 4*a*c; | |
if ( d < 0 ) { | |
cout << "\ngantolebas amonaxsni ar aqvs"; | |
} else if ( d == 0) { | |
x1 = -b/(2*a); | |
cout << "\namonaxsnebi:\n"; | |
cout << "\nx1 = x2 " << x1 << "\n"; | |
} else { | |
x1 = (-b - sqrt(d)) / (2*a); | |
x2 = (-b + sqrt(d)) / (2*a); | |
cout << "\namonaxsnebi:\n" | |
"x1 = " << x1 << "\t" << "x2 = " << x2 << "\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment