public class Test { public static void Main() { int a,b; Console.Write("a = "); a = int.Parse(Console.ReadLine()); Console.Write("b = "); b = int.Parse(Console.ReadLine()); if (a>b) Console.WriteLine("{0} > {1}", a, b); else if (a<b) Console.WriteLine("{0} < {1}", a, b); else Console.WriteLine("{0} = {1}", a, b); Console.ReadLine(); } }
Пример: a = 15 b = 28 15 < 28
2. using System;
class Program { public static void Main() { double y1, y2, h = 10; Console.WriteLine("x sin(x) cos(x)"); for (double x = 0; x <= 90; x = x+h) { y1 = Math.Sin(x*Math.PI/180); y2 = Math.Cos(x*Math.PI/180); Console.WriteLine("{0} {1:0.0000} {2:0.0000}",x,y1,y2); } Console.ReadKey(); } }
Answers & Comments
Verified answer
1.using System;
public class Test
{
public static void Main()
{
int a,b;
Console.Write("a = ");
a = int.Parse(Console.ReadLine());
Console.Write("b = ");
b = int.Parse(Console.ReadLine());
if (a>b) Console.WriteLine("{0} > {1}", a, b);
else if (a<b) Console.WriteLine("{0} < {1}", a, b);
else Console.WriteLine("{0} = {1}", a, b);
Console.ReadLine();
}
}
Пример:
a = 15
b = 28
15 < 28
2.
using System;
class Program
{
public static void Main()
{
double y1, y2, h = 10;
Console.WriteLine("x sin(x) cos(x)");
for (double x = 0; x <= 90; x = x+h) {
y1 = Math.Sin(x*Math.PI/180);
y2 = Math.Cos(x*Math.PI/180);
Console.WriteLine("{0} {1:0.0000} {2:0.0000}",x,y1,y2);
}
Console.ReadKey();
}
}
Результат:
x sin(x) cos(x)
0 0.0000 1.0000
10 0.1736 0.9848
20 0.3420 0.9397
30 0.5000 0.8660
40 0.6428 0.7660
50 0.7660 0.6428
60 0.8660 0.5000
70 0.9397 0.3420
80 0.9848 0.1736
90 1.0000 0.0000