Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- using namespace std;
- double circle (int r) {
- const double p = 3.1415926535897932384626433832795;
- double s;
- s = p * r * r;
- return s;
- }
- double rectangle (int a, int b) {
- int s;
- s = a * b;
- return s;
- }
- double triangle (int x, int y, int z) {
- double s, h;
- h = (x + y + z) / 2;
- s = sqrt(h * (h - x) * (h - y) * (h - z));
- return s;
- }
- int main () {
- cout << "What is your figure? ";
- string g;
- double a, b, r, x, y, z, k;
- cin >> g;
- if(g == "Circle" || g == "circle" || g == "rectangle" || g == "Rectangle" || g == "triangle" || g == "Triangel") {
- cout << "Enter your data ";
- if (g == "Circle" || g == "circle") {
- cin >> r;
- k = circle(r);
- }
- else if (g == "Rectangle" || g == "rectangle") {
- cin >> a >> b;
- k = rectangle(a, b);
- }
- else {
- cin >> x >> y >> z;
- k = triangle(x, y, z);
- }
- cout << k;
- } else {
- cout << "WRONG";
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment