using System;
namespace Task373
{
class Program
{
static void Main(string[] args)
{
// 1.
int[] array = new int[70];
GenerateRandomNumbers(array, 0, 201);
PrintNotZero(array);
// 2.
int[] arrayMul = new int[10];
InputIntArray(arrayMul);
Console.WriteLine(MultInInterval(arrayMul, 10, 20));
// 3.
Console.Write("Please, enter integer unsigned a = ");
byte a = byte.Parse(Console.ReadLine());
Console.Write("Please, enter integer unsigned b = ");
byte b = byte.Parse(Console.ReadLine());
Console.Write("Please, enter integer unsigned c = ");
byte c = byte.Parse(Console.ReadLine());
// Console.WriteLine(Sum(a) + Sum(b)*Sum(c));
Console.WriteLine(Sum(a) + Sum(b*c));
int number = 874;
int firstDigit = number / 100;
Console.Write(PrintTextDigit(firstDigit) + "стотин");
int secondDigit = (number % 100) / 10;
Console.Write(" " + PrintTextDigit(secondDigit) + "десет");
int thirdDigit = number % 10;
Console.Write(" и " + PrintTextDigit(thirdDigit));
// Sum the add numbers for end type 0
//int input = 0;
//int sum = 0;
//do
//{
// Console.Write("Please, enter the next number (type 0 for end): ");
// input = int.Parse(Console.ReadLine());
// if (input % 2 == 1)
// {
// sum += input;
// }
//} while (input != 0);
//Console.WriteLine(sum);
}
public static void GenerateRandomNumbers(int[] array, int min, int max)
{
Random randomGen = new Random();
for (int i = 0; i < array.Length; i++)
{
array[i] = randomGen.Next(min, max);
}
}
public static void PrintNotZero(int[] array)
{
for (int i = 0; i < array.Length; i++)
{
if (array[i] != 0) Console.WriteLine("arra[{0}] = {1}", i, array[i]);
}
}
public static void InputIntArray(int[] array)
{
for (int i = 0; i < array.Length; i++)
{
Console.Write("Please, eneter array[{0}] = ", i);
array[i] = int.Parse(Console.ReadLine());
}
}
public static int MultInInterval(int[] array, int min, int max)
{
int mul = 1;
for (int i = 0; i < array.Length; i++)
{
if (array[i] >= min && array[i] <= max)
{
mul *= array[i];
}
}
return mul;
}
public static ulong Sum(byte k)
{
int[] array = new int[k];
Random randGen = new Random();
ulong sum = 0;
for (int i = 0; i < array.Length; i++)
{
array[i] = randGen.Next();
if (array[i] % 2 == 0)
{
sum += (ulong)array[i];
}
}
return sum;
}
public static string PrintTextDigit(int digit)
{
switch (digit)
{
case 0:
return "Нула";
case 1:
return "Едно";
break;
case 2:
return "Две";
break;
case 3:
return "Три";
break;
case 4:
return "Четири";
break;
case 5:
return "Пет";
break;
case 6:
return "Шест";
break;
case 7:
return "Седем";
break;
case 8:
return "Осем";
break;
case 9:
return "Девет";
break;
default:
return "";
}
}
// Sum of a sequence of math expressions
public static double CalcMultiplication(int n)
{
double sum = 0;
for (int i = 2; i <= n; i++)
{
sum += 1 / (Math.Pow(i,2) - (i-1) + 1);
}
return sum;
}
// Generate random numbers find mul of only 2 digit numbers the last digit 5
public static int Sss(int k)
{
int mul = 1;
Random randomGen = new Random();
int[] array = new int[k];
for (int i = 0; i < array.Length; i++)
{
array[i] = randomGen.Next();
if (array[i] > 9 && array[i] < 100 && array[i] % 10 == 5)
{
mul *= array[i];
}
}
return mul;
}
}
}
Comments