Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.46 KB | None | 0 0
  1. 1.5
  2. using System;
  3.  
  4. namespace Test
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Console.WriteLine("Enter area of the circle");
  11. double r = double.Parse(Console.ReadLine());
  12. Console.WriteLine("Enter area of the square");
  13. double s = double.Parse(Console.ReadLine());
  14.  
  15. double radius = Math.Sqrt(r / Math.PI);
  16. double sqsize = Math.Sqrt(s);
  17. double sqdiag = Math.Sqrt(2) * sqsize;
  18.  
  19. if (sqdiag <= radius * 2) {
  20. Console.WriteLine("Square fits into the circle");
  21. } else {
  22. Console.WriteLine("Square does not fit into the circle");
  23. }
  24. }
  25. }
  26. }
  27.  
  28.  
  29. 2.6
  30. using System;
  31.  
  32. namespace Test
  33. {
  34. class Program
  35. {
  36. static void Main(string[] args)
  37. {
  38. Console.WriteLine("Enter number of points and then one point per line");
  39. int n = int.Parse(Console.ReadLine());
  40. for (int i = 0; i < n; ++i) {
  41. var input = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
  42. double x = input[0], y = input[1];
  43. if (x < 0 || x > Math.PI || y < 0 || y > Math.Sin(x)) {
  44. Console.WriteLine("Point is not in the area");
  45. } else {
  46. Console.WriteLine("Point is in the area");
  47. }
  48. }
  49. }
  50. }
  51. }
  52.  
  53.  
  54. 3.11
  55. using System;
  56.  
  57. namespace Test
  58. {
  59. class Program
  60. {
  61. static void Main(string[] args)
  62. {
  63. const int nExams = 4;
  64. Console.WriteLine("Mark the end of input with '-1'");
  65. int nGoodStudents = 0;
  66. int nBadStudents = 0;
  67. int sumGoodMarks = 0;
  68. while (true) {
  69. var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
  70. if (input[0] == -1) {
  71. break;
  72. }
  73. int a = input[0], b = input[1], c = input[2], d = input[3];
  74. if (a == 2 || b == 2 || c == 2 || d == 2) {
  75. ++nBadStudents;
  76. } else {
  77. ++nGoodStudents;
  78. sumGoodMarks += a + b + c + d;
  79. }
  80. }
  81. Console.WriteLine("There are {0} bad students", nBadStudents);
  82. Console.WriteLine("Average mark among good students is {0:f4}", 1.0 * sumGoodMarks / (nGoodStudents * nExams));
  83. }
  84. }
  85. }
  86.  
  87.  
  88.  
  89. 3.12
  90. using System;
  91.  
  92. namespace Test
  93. {
  94. class Program
  95. {
  96. static void Main(string[] args)
  97. {
  98. while (true) {
  99. Console.WriteLine("Enter r (or '-1' to exit)");
  100. double r = double.Parse(Console.ReadLine());
  101. if (r == -1) {
  102. break;
  103. }
  104. Console.WriteLine("Do you want to calcullate area of 'square', 'circle', or 'triangle'?");
  105. string type = Console.ReadLine();
  106. double s = -1;
  107. if (type == "square") {
  108. s = r * r;
  109. } else if (type == "circle") {
  110. s = Math.PI * r * r;
  111. } else if (type == "triangle") {
  112. s = 0.5 * Math.Sin(Math.PI / 3) * r * r;
  113. }
  114. Console.WriteLine(s);
  115. }
  116. }
  117. }
  118. }
  119.  
  120.  
  121.  
  122. 3.13
  123. using System;
  124.  
  125. namespace Test
  126. {
  127. class Program
  128. {
  129. static void Main(string[] args)
  130. {
  131. while (true) {
  132. Console.WriteLine("Enter A, B (or '-1' to exit)");
  133. var input = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
  134. if (input[0] == -1) {
  135. break;
  136. }
  137. double a = input[0], b = input[1];
  138.  
  139. Console.WriteLine("Do you want to calcullate area of 'rectangle', 'ring', or 'triangle'?");
  140. string type = Console.ReadLine();
  141. double s = -1;
  142. if (type == "rectangle") {
  143. s = a * b;
  144. } else if (type == "ring") {
  145. s = Math.PI * Math.Abs(a * a - b * b);
  146. } else if (type == "triangle") {
  147. double angle = Math.Acos((0.5 * a) / b);
  148. s = 0.5 * Math.Sin(angle) * a * b;
  149. }
  150. Console.WriteLine(s);
  151. }
  152. }
  153. }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement