/******************************************************************************
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 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;
}
static void test01()
{
int[] tt = {1,4,8 };
bool bb = IsSorted(tt);
Console.WriteLine("bb: {0}",bb);
Console.ReadKey();
AllNumbers All1 = new AllNumbers();
All1.LastOddValue();
AllNumbers All2 = new AllNumbers();
}
static void Main() {
Console.WriteLine("Hello World");
int[] tt = {1,4,8 };
bool bb = IsSorted(tt);
Console.WriteLine("bb: {0}",bb);
test01();
}
}
using System;
public class AllNumbers
{
//صفات
private int[] arrNum;
//بناء
public AllNumbers()
{
this.arrNum = new int[]{ 7,5,8,9,3,4};
}
//عمليات
public int LastOddValue()
{
int result=0;
for (int i = 0; i < this.arrNum.Length; i++)
{
if (this.arrNum[i] % 2 == 1)
result = this.arrNum[i];
}
return result;
}
public int LastOddValue1()
{
for (int i = this.arrNum.Length -1; i >=0 ; i--)
{
if (this.arrNum[i] % 2 == 1)
return this.arrNum[i];
}
return -1;
}
public static int Above(int[] arr, int num)
{
return 0;
}
}
class Stam
{
public void test()
{
int[] arr = new int[100];
int num;
int total = 0;
Console.Write("Please enter num:");
num = int.Parse(Console.ReadLine());
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] < num)
total += arr[i];
}
Console.WriteLine(total);
}
}