DateTime dateTick = new DateTime(Int64.Parse(Console.ReadLine()));
int[] inputArray = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
DateTime date2 = new DateTime(inputArray[0], inputArray[1], inputArray[2], inputArray[3], inputArray[4], inputArray[5], inputArray[6]);
Console.WriteLine(dateTick.CompareTo(date2));
int input = Convert.ToInt32(Console.ReadLine());
int oddNumbers = 0, evenNumbers = 0;
while (input>0)
{
int temp = input % 10;
if (temp % 2 == 0) evenNumbers += 1;
else oddNumbers += 1;
input /= 10;
}
if (evenNumbers > oddNumbers) Console.WriteLine("2");
else if (oddNumbers > evenNumbers) Console.WriteLine("1");
else Console.WriteLine("0");
int input = Int32.Parse(Console.ReadLine());
int firstNum = input / 10000;
input %= 10000;
int secondNum = input / 1000;
input %= 100;
int thirdNum = input / 10;
int fourthNum = input % 10;
Console.WriteLine("{0}{1}{2}{3}", firstNum, secondNum, thirdNum, fourthNum);
int input = Int32.Parse(Console.ReadLine());
input /= 100;
input *= 100;
Console.WriteLine(input);
string input = Console.ReadLine();
int indexOfPlus = input.IndexOf('+'),
indexOfMultiple = input.IndexOf('*'),
indexOfEqual = input.IndexOf('=');
string numA = input.Substring(0, input.Length - (input.Length - indexOfPlus)),
numB = input.Substring(indexOfPlus + 1, (indexOfMultiple-1-indexOfPlus)),
numC = input.Substring(indexOfMultiple + 1, (indexOfEqual - 1 - indexOfMultiple));
int rezult = Int32.Parse(numA) + Int32.Parse(numB) * Int32.Parse(numC);
Console.WriteLine(rezult);
int[] pointA = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
int[] pointB = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
int[] pointC = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
double lineAB = Math.Sqrt(Math.Pow(pointA[0] - pointB[0], 2) + Math.Pow(pointA[1] - pointB[1], 2));
double lineBC = Math.Sqrt(Math.Pow(pointB[0] - pointC[0], 2) + Math.Pow(pointB[1] - pointC[1], 2));
double lineAC = Math.Sqrt(Math.Pow(pointA[0] - pointC[0], 2) + Math.Pow(pointA[1] - pointC[1], 2));
double perimetr = lineAB + lineBC + lineAC;
Console.WriteLine("{0:f2}", perimetr);
int[] input = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
int lengthOfRectAngle = Math.Abs(input[0] - input[2]), widthOfRectAngle = Math.Abs(input[1] - input[2]),
sOfRectangle = lengthOfRectAngle * widthOfRectAngle;
Console.WriteLine(sOfRectangle);
double[] input = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToDouble);
double rezult = Math.Sqrt(Math.Abs(input[0] * input[1]));
Console.WriteLine("{0:f2}", rezult);
char input = Char.Parse(Console.ReadLine());
byte firstSymbol = (byte)input;
for (int i = 0; i < 6; i++)
{
Console.Write("{0} ",(char)firstSymbol);
firstSymbol++;
}
Console.WriteLine();
static void Main(string[] args)
{
int n = Int32.Parse(Console.ReadLine());
int[] myarray = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
Console.WriteLine(NumMin(myarray) + " " + NumMax(myarray));
}
public static int NumMax (int[] array)
{
int a = array.Max();
return a;
}
public static int NumMin(int[] array)
{
int a = array.Min();
return a;
}
int n = Int32.Parse(Console.ReadLine());
int [] myArray = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
int numberOfZerro =0;
for (int i = 0; i < n; i++)
{
if (myArray[i] == 0) numberOfZerro++;
}
Console.WriteLine(numberOfZerro);
int n = Int32.Parse(Console.ReadLine());
int [] myArray = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
int maxValue = myArray.Max();
int minValue = myArray.Min();
int indexOfMax = Array.IndexOf(myArray, maxValue);
int indexOfMin = Array.IndexOf(myArray, minValue);
myArray[indexOfMin] = maxValue;
myArray[indexOfMax] = minValue;
for (int i = 0; i < n; i++)
{
Console.Write(myArray[i] + " ");
}
Console.WriteLine();
int n = Int32.Parse(Console.ReadLine());
int[] myArray = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
foreach (var item in myArray)
{
if (item != myArray[n-1]) Console.Write(item + ",");
else Console.Write(item + ".");
}
Самый простой вариант. И самый рабочий.
uint input = UInt32.Parse(Console.ReadLine());
uint sum = 0;
while (input>0)
{
sum += input % 10;
input /= 10;
}
Console.WriteLine(sum);
uint input = UInt32.Parse(Console.ReadLine());
int [] count = Array.ConvertAll(Console.ReadLine().Split(' '), Convert.ToInt32);
double sum = 0;
double sr = 0;
for (int i = 0; i < count.Length; i++)
{
sum += count[i];
}
sr = sum / input;
Console.WriteLine(Math.Round(sr, 1));
Компилятор говно!
Маленькая загвоздка. Число "00" является двузначным четным числом, но эту проверку она не пройдет.
uint inp = UInt32.Parse(Console.ReadLine());
if (inp > 9 && inp < 100 && inp%2==0) Console.WriteLine("YES");
else Console.WriteLine("NO");
string [] str = Console.ReadLine().Split(' ');
int[] input = { Convert.ToInt32(str[0]), Convert.ToInt32(str[1]), Convert.ToInt32(str[2]), Convert.ToInt32(str[3])};
int a = input[0];
int b = input[1];
int c = input[2];
int d = input[3];
int raz = 0;
int raz2 = 0;
if (a > b) raz = a - b;
if (a < b) raz = b - a;
if (b > c) raz2 = b - c;
if (b < c) raz2 = c - b;
if (raz > raz2) raz = raz2;
if (c > d) raz2 = c - d;
if (c < d) raz2 = d - c;
if (raz > raz2) raz = raz2;
if (d > a) raz2 = d - a;
if (d < a) raz2 = a - d;
if (raz > raz2) raz = raz2;
Console.WriteLine(raz);
int num = 256;
int rezult2 = num * num;
int rezult =0;
while (num>0)
{
rezult += num % 10;
num /= 10;
}
Console.WriteLine(rezult + " "+rezult2);
string strin = ("[ 1024 ]");
strin = strin.Replace("[", "");
strin = strin.Replace("]", "");
Console.WriteLine(strin);
string str2 = strin;
str2 = str2.TrimStart();
str2 = str2.Insert(0, "[") + "]";
Console.WriteLine(str2);
string str3 = strin;
str3 = str3.TrimEnd();
str3 = str3.Insert(0, "[") + "]";
Console.WriteLine(str3);
string str1 = strin;
str1 = str1.Trim();
str1 = str1.Insert(0, "[") + "]";
Console.WriteLine(str1);
Круто. Твой код добавляет возможность искать сразу несколько слов в скобках. Я лишь добавил строку, которая разделяет эти слова пробелом))
s2 = s2 + " ";
в цикл
if (s1[i] == ')')
String fraze1 = Console.ReadLine();
String fraze2 = Console.ReadLine();
Console.WriteLine(fraze1.CompareTo(fraze2));
Console.WriteLine(string.Compare(fraze1.ToLower(),fraze2.ToLower())) ;
string fraze = Console.ReadLine();
string[] byone = fraze.Split(' ');
for (int i = 0; i<byone.Length; i++)
{
Console.Write(byone[i]+"\n");
}