Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace ooo
  5. {
  6.     class MainClass
  7.     {
  8.         public static void choose(uint r)
  9.         {
  10.             Console.Write ("Введите номер операции: ");
  11.  
  12.             uint x = Convert.ToUInt32 (Console.ReadLine ());
  13.             switch (x)
  14.             {
  15.             case 1:
  16.                 Console.WriteLine ("S треугольника со стороной {0} равна {1:f3}", r, trgle (r));
  17.                 break;
  18.             case 2:
  19.                 Console.WriteLine ("S квадрата со стороной {0} равна {1}", r, sqr (r));
  20.                 break;
  21.             case 3:
  22.                 Console.WriteLine ("S окружности со стороной {0} равна {1:f3}", r, circ (r));
  23.                 break;
  24.             }
  25.  
  26.             if (x!=1 && x!=2 && x!=3)
  27.             {
  28.                 Console.WriteLine ("Ошибка");
  29.                 choose (r);
  30.             }
  31.             return;
  32.         }
  33.         private static double trgle(uint j)
  34.         {
  35.             double S = Math.Sqrt(3)*j*j/4;
  36.             return S;
  37.         }
  38.         private static double circ(uint j)
  39.         {
  40.             double S = Math.PI * j * j;
  41.             return S;
  42.         }
  43.         private static uint sqr(uint j)
  44.         {
  45.             uint S =  j * j;
  46.             return S;
  47.         }
  48.         public static void Main (string[] args)
  49.         {
  50.             Console.Write (" 1 - для треугольника \n 2 - для квадрата \n 3 - для окружности \n Введите количество фигур: ");
  51.             uint Q = Convert.ToUInt32 (Console.ReadLine());
  52.             for (int i = 0; i < Q; i++)
  53.             {
  54.                 Console.Write ("r = ");
  55.                 uint r = Convert.ToUInt32 (Console.ReadLine ());
  56.                 choose (r);
  57.             }
  58.             Console.ReadKey ();
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement