Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int index=0;
- int max=0;
- int n;
- cout << "How many right-angled triangles do you wish to calculate: "<<endl;
- cin >> n;
- int* a = new int[n];
- int* b = new int[n];
- int* s = new int[n];
- for (int i = 0; i < n; i++) { //loop for entering information about the triangle and calculating the area
- cout << "Enter cathetus a for triangle number: " << i + 1<<endl;
- cin >> a[i];
- cout << "Enter cathetus b for triangle number: " << i + 1<<endl;
- cin >> b[i];
- s[i] = (a[i] * b[i]) / 2;
- }
- for (int i = 0; i < n; i++) { //loop finding the largest area of a triangle
- if (s[i] > max) {
- max = s[i];
- index = i;
- }
- }
- cout << "Triangle number "<<index+1<<" has the biggest area of "<<max<<" square centimeters!";
- }
Advertisement
Add Comment
Please, Sign In to add comment