Скачиваний:
22
Добавлен:
01.05.2014
Размер:
908 б
Скачать
#include<iostream.h>;//Stream library
#include<math.h>//Math library
#include<values.h>//Values library
#include<conio.h>//Screen library

float sq(float r0) // calculating square
{
    float square;
    square = 6*r0*r0/sqrt(3)-M_PI_2*r0*r0;
    return square;
}

int check(float r0) // check correctly of radius
{
    if ((r0<0) || (r0>100))
    {
      cout << "Invalid radius";
      return 0;
    }
    return 1;

}


void main(void)//Main function
{
    float       r       = 0; //Radius of circle



    clrscr();
    cout << "\n";
    cout <<
    "Program calculating square of figure.\n";
    do
    {

      do
      {
	cout << "\nType radius [0," << "100" << "]:\n" << "r=";
	cin >> r;
      }
      while ((!check(r)));
    cout << "Square of figure is: " << sq(r); //Result
    cout << "\n" << "Press Esc for exit.";
    }
    while(getch()!=27);
}
Соседние файлы в папке Вычисление площади фигуры