Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
72
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.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     // В данном классе инкапсулируются статические методы
  9.     // выполняющие простейшие операции
  10.     static class MyMath
  11.     {
  12.         // Целая часть числа
  13.         static public int round(double d)
  14.         {
  15.             return (int)d;
  16.         }
  17.  
  18.         // Дробная часть числа
  19.         static public double doub(double d)
  20.         {
  21.             return d - (int)d;
  22.         }
  23.  
  24.         // Квадрат числа
  25.         static public double sqr(double d)
  26.         {
  27.             return d * d;
  28.         }
  29.  
  30.         // Квадратный корень числа
  31.         static public double sqrt(double d)
  32.         {
  33.             return Math.Sqrt(d);
  34.         }
  35.     }
  36.  
  37.     class Program
  38.     {
  39.         static void Main(string[] args)
  40.         {
  41.             Console.WriteLine("Исходное число: 12.44\n\n--------------------\n");
  42.             Console.WriteLine("Целая часть: {0}",MyMath.round(d: 12.44));
  43.             Console.WriteLine("Дробная часть числа: {0}",MyMath.doub(d: 12.44));
  44.             Console.WriteLine("Квадрат числа: {0:#.##}",MyMath.sqr(d: 12.44));
  45.             Console.WriteLine("Квадратный корень числа: {0:#.###}",MyMath.sqrt(d: 12.44));
  46.  
  47.             Console.ReadLine();
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement