Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.5
- using System;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter area of the circle");
- double r = double.Parse(Console.ReadLine());
- Console.WriteLine("Enter area of the square");
- double s = double.Parse(Console.ReadLine());
- double radius = Math.Sqrt(r / Math.PI);
- double sqsize = Math.Sqrt(s);
- double sqdiag = Math.Sqrt(2) * sqsize;
- if (sqdiag <= radius * 2) {
- Console.WriteLine("Square fits into the circle");
- } else {
- Console.WriteLine("Square does not fit into the circle");
- }
- }
- }
- }
- 2.6
- using System;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter number of points and then one point per line");
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; ++i) {
- var input = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
- double x = input[0], y = input[1];
- if (x < 0 || x > Math.PI || y < 0 || y > Math.Sin(x)) {
- Console.WriteLine("Point is not in the area");
- } else {
- Console.WriteLine("Point is in the area");
- }
- }
- }
- }
- }
- 3.11
- using System;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- const int nExams = 4;
- Console.WriteLine("Mark the end of input with '-1'");
- int nGoodStudents = 0;
- int nBadStudents = 0;
- int sumGoodMarks = 0;
- while (true) {
- var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
- if (input[0] == -1) {
- break;
- }
- int a = input[0], b = input[1], c = input[2], d = input[3];
- if (a == 2 || b == 2 || c == 2 || d == 2) {
- ++nBadStudents;
- } else {
- ++nGoodStudents;
- sumGoodMarks += a + b + c + d;
- }
- }
- Console.WriteLine("There are {0} bad students", nBadStudents);
- Console.WriteLine("Average mark among good students is {0:f4}", 1.0 * sumGoodMarks / (nGoodStudents * nExams));
- }
- }
- }
- 3.12
- using System;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true) {
- Console.WriteLine("Enter r (or '-1' to exit)");
- double r = double.Parse(Console.ReadLine());
- if (r == -1) {
- break;
- }
- Console.WriteLine("Do you want to calcullate area of 'square', 'circle', or 'triangle'?");
- string type = Console.ReadLine();
- double s = -1;
- if (type == "square") {
- s = r * r;
- } else if (type == "circle") {
- s = Math.PI * r * r;
- } else if (type == "triangle") {
- s = 0.5 * Math.Sin(Math.PI / 3) * r * r;
- }
- Console.WriteLine(s);
- }
- }
- }
- }
- 3.13
- using System;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true) {
- Console.WriteLine("Enter A, B (or '-1' to exit)");
- var input = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
- if (input[0] == -1) {
- break;
- }
- double a = input[0], b = input[1];
- Console.WriteLine("Do you want to calcullate area of 'rectangle', 'ring', or 'triangle'?");
- string type = Console.ReadLine();
- double s = -1;
- if (type == "rectangle") {
- s = a * b;
- } else if (type == "ring") {
- s = Math.PI * Math.Abs(a * a - b * b);
- } else if (type == "triangle") {
- double angle = Math.Acos((0.5 * a) / b);
- s = 0.5 * Math.Sin(angle) * a * b;
- }
- Console.WriteLine(s);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement