Advertisement
EmoRz

Master_Numbers

Apr 5th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var n = int.Parse(Console.ReadLine());
  10.  
  11.             for (int i = 1; i <= n; i++)
  12.             {
  13.                 DivBySeven(i);
  14.                 Even(i);
  15.                 Palindrom(i);
  16.                 if (Palindrom(i) && DivBySeven(i) &&Even(i))
  17.                 {
  18.                     Console.WriteLine(i);
  19.                 }
  20.             }
  21.         }
  22.         public static bool Palindrom(int i)
  23.         {
  24.             var temp = 0;
  25.             var digit = 0;
  26.             var check = false;
  27.             var res = i;
  28.             //
  29.             while (i > 0)
  30.             {
  31.                 digit = i % 10;
  32.                 temp = temp * 10 + digit;
  33.                 i = i / 10;
  34.             }
  35.             if (res == temp)
  36.             {
  37.                 check = true;
  38.             }
  39.  
  40.             return check;
  41.         }
  42.         public static bool Even(int i)
  43.         {
  44.             var temp = 0;
  45.             var check = false;
  46.             var res = i;
  47.             while (i > 0)
  48.             {
  49.                 temp = i % 10;
  50.                 if (temp % 2 == 0)
  51.                 {
  52.                     check = true;
  53.                     break;
  54.                 }
  55.                 i /= 10;
  56.             }
  57.  
  58.             return check;
  59.         }
  60.         public static bool DivBySeven(int i)
  61.         {
  62.             var temp = 0;
  63.             var sum = 0;
  64.             var res = i;
  65.             var ch = false;
  66.             while (i>0)
  67.             {
  68.                 temp = i % 10;
  69.                 sum += temp;
  70.                 i /= 10;
  71.             }
  72.             if (sum % 7 == 0)
  73.             {
  74.                 ch = true;
  75.             }
  76.             return ch;
  77.         }
  78.  
  79.         private static void GeometryCalc()
  80.         {
  81.             var type = Console.ReadLine().ToLower();
  82.             //
  83.             string[] arr = { "triangle", "square", "rectangle", "circle" };
  84.             for (int i = 0; i < arr.Length; i++)
  85.             {
  86.                 if (type == arr[0])
  87.                 {
  88.                     var a = double.Parse(Console.ReadLine());
  89.                     var h = double.Parse(Console.ReadLine());
  90.                     var prt = Triangle(a, h);
  91.                     Console.WriteLine($"{prt:f2}");
  92.                     break;
  93.                 }
  94.                 else if (type == arr[1])
  95.                 {
  96.                     var a = double.Parse(Console.ReadLine());
  97.                     var prt = Square(a);
  98.                     Console.WriteLine($"{prt:f2}");
  99.                     break;
  100.                 }
  101.                 else if (type == arr[2])
  102.                 {
  103.                     var a = double.Parse(Console.ReadLine());
  104.                     var b = double.Parse(Console.ReadLine());
  105.                     var prt = Rectangle(a, b);
  106.                     Console.WriteLine($"{prt:f2}");
  107.                     break;
  108.                 }
  109.                 else if (type == arr[3])
  110.                 {
  111.                     var r = double.Parse(Console.ReadLine());
  112.                     var prt = Circle(r);
  113.                     Console.WriteLine($"{prt:f2}");
  114.                     break;
  115.                 }
  116.             }
  117.         }
  118.         public static double Circle(double r)
  119.         {
  120.             var area = Math.PI * Math.Pow(r, 2);
  121.             return area;
  122.         }
  123.         public static double Square(double a)
  124.         {
  125.             var area = a * a;
  126.             return area;
  127.         }
  128.         public static double Rectangle(double a, double b)
  129.         {
  130.             var area = a * b;
  131.             return area;
  132.         }
  133.         public static double Triangle(double a, double h)
  134.         {
  135.             var area = a*h/2;
  136.             return area;
  137.         }
  138.         private static void CubeProperty()
  139.         {
  140.             double n = double.Parse(Console.ReadLine());
  141.             string pro = Console.ReadLine();
  142.             //
  143.             if (pro == "face")
  144.             {
  145.                 var prt = Face(n);
  146.                 Console.WriteLine($"{prt:f2}");
  147.             }
  148.             else if (pro == "space")
  149.             {
  150.                 var prt = Space(n);
  151.                 Console.WriteLine($"{prt:f2}");
  152.             }
  153.             else if (pro == "volume")
  154.             {
  155.                 Console.WriteLine($"{Volume(n):f2}");
  156.             }
  157.             else if (pro == "area")
  158.             {
  159.                 var prt = Surface(n);
  160.                 Console.WriteLine($"{prt:f2}");
  161.  
  162.             }
  163.         }
  164.         public static double Space(double n)
  165.         {
  166.             var calc = 3 * Math.Pow(n, 2);
  167.             var prt = Math.Sqrt(calc);
  168.             return prt;
  169.  
  170.         }
  171.         public static double Face(double n)
  172.         {
  173.             var calc = 2 * Math.Pow(n, 2);
  174.             var prt = Math.Sqrt(calc);
  175.             return prt;
  176.  
  177.         }
  178.         public static double Volume(double n)
  179.         {
  180.             var volu = Math.Pow(n, 3);
  181.             return volu;
  182.         }
  183.         public static double Surface(double n)
  184.         {
  185.             var face = 6*Math.Pow(n,2);
  186.             return face;
  187.         }
  188.         private static void CenterPoints()
  189.         {
  190.             int x1 = int.Parse(Console.ReadLine());
  191.             int y1 = int.Parse(Console.ReadLine());
  192.             int x2 = int.Parse(Console.ReadLine());
  193.             int y2 = int.Parse(Console.ReadLine());
  194.             //
  195.             Check(x1, y1, x2, y2);
  196.         }
  197.         public static void Check(int x1, int y1, int x2, int y2)
  198.         {
  199.             var xDist = 0;
  200.             var yDist = 0;
  201.             var x = 0;
  202.             var y = 0;
  203.             if (x1 >= x2)
  204.             {
  205.                 xDist = x1 - x2;
  206.                 x = x2;
  207.             }
  208.             else if (x1 < x2)
  209.             {
  210.                 xDist = x2 - x1;
  211.                 x = x1;
  212.             }
  213.             if (y1 >= y2)
  214.             {
  215.                 yDist = y1 - y2;
  216.                 y = y2;
  217.             }
  218.             else if (y1 < y2)
  219.             {
  220.                 yDist = y2 - y1;
  221.                 y = y1;
  222.             }
  223.             Console.WriteLine($"({x}, {y})");
  224.         }
  225.         public static void Print(int num)
  226.         {
  227.             string prt = "";
  228.             string[] digitsWord = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
  229.             prt = digitsWord[LastDigit(num)];
  230.             Console.WriteLine(prt);
  231.         }
  232.         public static int LastDigit(int num)
  233.         {
  234.             int last = num % 10;
  235.             return last;
  236.  
  237.         }
  238.         private static void Gretaer()
  239.         {
  240.             int a = int.Parse(Console.ReadLine());
  241.             int b = int.Parse(Console.ReadLine());
  242.             int c = int.Parse(Console.ReadLine());
  243.             //
  244.             var greatest = 0;
  245.             if (Max(a, b) > c)
  246.             {
  247.                 greatest = Max(a, b);
  248.             }
  249.             else
  250.             {
  251.                 greatest = c;
  252.             }
  253.             Console.WriteLine(greatest);
  254.         }
  255.         public static int Max(int a, int b)
  256.         {
  257.             int greater = 0;
  258.             if (a>b)
  259.             {
  260.                 greater = a;
  261.             }
  262.             else
  263.             {
  264.                 greater = b;
  265.             }
  266.             return greater;
  267.         }
  268.         public static void Greeting(string name)
  269.         {
  270.             Console.WriteLine($"Hello, {name}!");
  271.         }
  272.     }
  273. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement