stkirov

Problem 1 - Math Expression

Oct 26th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. //Problem 3 – Trapezoid
  2. //Write a program that prints on the console the border of a trapezoid by given number N.
  3. //The width of the top side of the trapezoid must be exactly N.
  4. //The width of the bottom side of the trapezoid must be exactly 2 * N.
  5. //The height of the trapezoid must be exactly N + 1.
  6. //Also the top right and the bottom right angle of the trapezoid must be equal to 90 degrees.
  7. //See the examples bellow.
  8. //Input
  9. //The input data is being read from the console.
  10. //On the only line in the console you are given an integer number N, showing the width of the smallest trapezoid side.
  11. //The input data will always be valid and in the format described. There is no need to check it explicitly.
  12. //Output
  13. //The output data must be printed on the console.
  14. //You must write the border of the described trapezoid on the console.
  15. //Use the symbol “*” (asterisk) to mark the border of the trapezoid.
  16. //Use the symbol “.” (dot) to illustrate the empty spaces outside and inside the trapezoid.
  17. //Constraints
  18. //•   The number N is a positive integer between 3 and 39, inclusive.
  19. //•   Allowed working time for your program: 0.25 seconds.
  20. //•   Allowed memory: 16 MB.
  21.  
  22. using System;
  23.  
  24. class Program
  25. {
  26.     static void Main()
  27.     {
  28.         decimal n = decimal.Parse(Console.ReadLine());
  29.         decimal m = decimal.Parse(Console.ReadLine());
  30.         decimal p = decimal.Parse(Console.ReadLine());
  31.         double mod = Math.Truncate((double)m % 180);
  32.  
  33.         decimal first = (n*n) + (1/ (m*p) + 1337);
  34.         decimal second = n - (128.523123123M * p);
  35.         decimal third = (decimal)Math.Sin(mod);
  36.         Console.WriteLine(Math.Round(((first/second) + third), 6));
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment