БД Коды
.docxВозраст человека
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
string con;
Console.WriteLine("Введите возраст человека");
con = Console.ReadLine();
int vozrast = Convert.ToInt16(con);
if ((vozrast >= 6) && (vozrast <= 16))
vozrast = 1;
if ((vozrast >= 17) && (vozrast <= 21))
vozrast = 2;
if ((vozrast >= 22) && (vozrast <= 60))
vozrast = 3;
switch (vozrast)
{
case 1:
Console.WriteLine ("Ты учишься в школе");
break;
case 2:
Console.WriteLine ("Ты учишься в институте");
break;
case 3:
Console.WriteLine ("Вы работаете");
break;
default:
Console.WriteLine ("Вы на заслуженном отдыхе");
break;
Console.ReadLine();
}
}
}
}
Радиус круга
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
double S;
double r;
S=10;
r=Math.Sqrt (S/3.14);
Console.WriteLine ("Радиус равен "+r);
Console.ReadLine();
}
}
}
Вывести таблицу умножения до 5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
for (int i = 1; i <= 5; i++)
{
for (int j = 1; j <= 5; j++)
Console.WriteLine(i + "*" + j + "=" + i * j);
Console.ReadLine();
}
}
}
}
Запрет деления на 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int rst;
for (int i = -2; i < 3; i++)
{
rst = i != 0 ? 100 / i : 29;
if (i != 0)
Console.WriteLine(rst);
}
Console.ReadLine();
}
}
}
Оператор выбора
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
String Str;
Console.WriteLine("Введите строку: ");
Str = Console.ReadLine();
if (Str.Length < 3)
Console.WriteLine("\nВ данной строке меньше 5 символов");
else if ((Str.Length > 4) && (Str.Length <= 100))
Console.WriteLine("\nВ данной строке {0} символов", Str.Length);
else Console.WriteLine("\nВ данной строке больше 100 символов");
Console.ReadLine();
}
}
}