/******************************************************************************
Online C# Compiler.
Code, Compile, Run and Debug C# program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
using System;
class HelloWorld {
//1
public static bool IsSorted1(int[] arr)
{
int count = 0;
for (int i = 0; i < arr.Length - 1; i++)
{
if (arr[i] < arr[i + 1])
count++;
}
if (count == arr.Length -1)
return true;
return false;
}
//2
public static bool IsSorted(int[] arr)
{
for (int i = 0; i < arr.Length-1; i++)
{
if (arr[i] > arr[i + 1])
return false;
}
return true;
}
public static bool IsSorted4(int[] arr)
{
for (int i = arr.Length - 1; i > 0; i--)
{
if (arr[i-1] > arr[i])
return false;
}
return true;
}
public static int Add(int a, int b)
{
return a + b;
}
public static bool IsOK(int[] arr)
{
Console.WriteLine(arr.Length);
if (arr.Length != 2)
return false;
if (arr[0] == arr[1])
{
return true;
}
return false;
}
public static bool IsOK2(int[] arr)
{
int start = 0;
int end = arr.Length -1;
while (start < end)
{
if (arr[start] != arr[end])
{
return false;
}
start +=1;
end -=1;
}
return true;
}
public static bool IsSorted2(int[] arr)
{
bool b=true;
for (int i = 0; i < arr.Length - 1; i++)
{
b = b && (arr[i] < arr[i + 1]);
}
return b;
}
public static int CountQuestion(int[] arr)
{
int count=0;
//مثال للمعطيات
int[] Questions = {1,2,3,2,5,5,3,4,1,4,3,3 };
for (int i = 1; i < Questions.Length; i+=3)
{
if (Questions[i] == Questions[i + 1])
count++;
}
return count;
}
public static int MaxArray1(int[] arr)
{
int max = arr[0];
int mi = 0;
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] > max)
{
max = arr[i];
mi = i;
}
}
return mi;
}
public static bool CountArray(int[] arr)
{
int[] Digits = new int[10];
for (int i = 0; i < Digits.Length; i++)
{
Digits[i] = 0;
}
for (int i = 0; i < arr.Length; i++)
{
Digits[arr[i]]++;
}
for (int i = 0; i < Digits.Length; i++)
{
if (Digits[i] != i || Digits[i] != 0)
return false;
}
return true;
}
static void Main() {
Console.WriteLine("Hello World");
}
}