Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main() {
- using namespace std;
- bool iscorrect = true;
- cout << "This program finds the triangle with the largest radius of the circumscribed circle\n";
- int n;
- do {
- cout << "Enter the number of triangles n (n > 2 and n < 10)\n";
- cin >> n;
- if ((n > 1) && (n < 10)) {
- iscorrect = false; }
- else {
- cout << "This is a mistake. Please enter again!\n";
- iscorrect = true;
- }
- }
- while (iscorrect);
- double a;
- double b;
- double c;
- int nomb = 0;
- double p;
- double radius[10];
- double max = 0;
- for(int i = 0; i < n; i++) {
- cout << "Enter the sides of triangle nomber " << i+1 << "\n";
- do {
- do {
- cout << " First side = \n";
- cin >> a;
- if (a > 0) {
- iscorrect = false; }
- else {
- cout << "This is a mistake. Please enter again!\n";
- iscorrect = true;
- }
- }
- while (iscorrect);
- do {
- cout << " Second side = \n";
- cin >> b;
- if (b > 0) {
- iscorrect = false; }
- else {
- cout << "This is a mistake. Please enter again!\n";
- iscorrect = true;
- }
- }
- while (iscorrect);
- do {
- cout << " Third side = \n";
- cin >> c;
- if (c > 0) {
- iscorrect = false; }
- else {
- cout << "This is a mistake. Please enter again!\n";
- iscorrect = true;
- }
- }
- while (iscorrect);
- if ((a + b > c) && (a + c > b) && (b + c > a)) {
- iscorrect = false; }
- else {
- i = i -1;
- cout << "This is a mistake. The sides of the triangle must satisfy the condition (a + b > c and a + c > b and b + c > a).\nPlease enter sides again!\n";
- }
- p = (a + b + c) / 2;
- radius[i] = (a * b * c) / (4 * sqrt(p * (p - a) * (p - b) * (p - c)));
- if (max < radius[i]) {
- max = radius[i];
- nomb = i;
- }
- }
- while (iscorrect);
- }
- cout << " Triangle number " << nomb + 1 << " has the largest radius of the circumscribed circle = " << max << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement