SlideShare ist ein Scribd-Unternehmen logo
1 von 12
namespace ConsoleApplication15
{
class Program
{
static void Main(string[] args)
{
Console.Write("a too: ");
int a = int.Parse(Console.ReadLine());
Console.Write("b too: ");
int b = int.Parse(Console.ReadLine());
Console.Write("c too: ");
int c = int.Parse(Console.ReadLine());
if (a > b)
if (b > c)
Console.WriteLine("min: c too {0}", c);
else
Console.WriteLine("min: b too {0}", b);
else if (a>c)
Console.WriteLine("min: c too {0}", c);
else
Console.WriteLine("min: a too {0}", a);
Console.ReadLine();
}
}
}
namespace ConsoleApplication17
{
class Program
{
static void Main(string[] args)
{
Console.Write("age: ");
int a = int.Parse(Console.ReadLine());
Console.WriteLine("sex: ");
string k = Console.ReadLine();
if ((a >= 18) && ( k == "er"))
Console.Write("tseregt yvj bolno");
else
Console.Write("tseregt yvj bolohgui");
Console.ReadLine();
}
}
}
namespace ConsoleApplication18
{
class Program
{
static void Main(string[] args)
{
int s = 1;
Console.Write("n!: ");
int n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
s *= i;
Console.WriteLine(s);
Console.ReadLine();
}
}
}
namespace ConsoleApplication23
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("N ширхэг тооны нийлбэр олох");
Console.Write("N тоог оруулна уу: ");
int n=int.Parse(Console.ReadLine());
int s = 0;
for (int i = 1; i <= n; i++)
{
Console.Write("{0}-р тоог оруулна уу: ", i);
s += (int.Parse(Console.ReadLine()));
}
Console.WriteLine("{0} ширхэг тооны нийлбэр: {1} ",n,s);
Console.ReadLine();
}
}
}
namespace ConsoleApplication25
{
class Program
{
static void Main(string[] args)
{
string[] temdegtmassiv;
temdegtmassiv = new string[100];
Console.WriteLine("neg hemjeest massiviin gishuudiig oruul: ");
int n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
Console.Write("{0}-r gishuunii utga oruulna uu: ", i);
temdegtmassiv[i] = Console.ReadLine();
}
foreach (string s in temdegtmassiv)
Console.Write(s);
Console.ReadLine();
}
}
}
namespace ConsoleApplication26
{
class Program
{
static void Main(string[] args)
{
int[] massivA = new int[100];
Console.WriteLine("neg hemjeest massiviin gishuudiig oruul: ");
int n = int.Parse(Console.ReadLine());
int s=0;
for (int i = 1; i <= n; i++)
{
Console.Write("{0}-r gishuunii utga oruulna uu: ", i);
massivA[i] = int.Parse(Console.ReadLine());
s += massivA[i];
}
Console.Write("niilber{0}",s);
Console.ReadLine();
}
}
}
 Өгөгдсөн тоог хөрвүүлэх
namespace ConsoleApplication32
{
class Program
{
static void Main(string[] args)
{
string s = Console.ReadLine();
string k = "";
int j = s.Length-1;
for (int i = 0; i < s.Length; i++)
{
k=k.Insert(i,s.Substring(j, 1));
j--;
}
Console.WriteLine(k);
Console.ReadLine();
}
}
}
 Өгөгдсөн тоо палиндром тоо эсэх
namespace ConsoleApplication32
{
class Program
{
static void Main(string[] args)
{
string s = Console.ReadLine();
string k = "";
int j = s.Length-1;
for (int i = 0; i < s.Length; i++)
{
k=k.Insert(i,s.Substring(j, 1));
j--;
}
if (int.Parse(s) == int.Parse(k))
Console.WriteLine("palindrom mon");
else
Console.WriteLine("palindrom bish");
Console.ReadLine();
}
}
}
 Өгөгдсөн тоо тэгш эсвэл сондгой эсэхийг тодорхойлох
namespace ConsoleApplication34
{
class Program
{
static void Main(string[] args)
{
double m = double.Parse(Console.ReadLine());
string s=Convert.ToString(m/2);
if (s.Contains("."))
Console.WriteLine("sondgoi");
else
Console.WriteLine("tegsh");
Console.ReadLine();
}
}
}
 Өгөгдсөн тооны цифрийн нийлбэр тэгш эсвэл сондгой эсэхийг тодорхойлох
namespace ConsoleApplication40
{
class Program
{
static void Main(string[] args)
{
Console.Write("too oruul=");
string m = Console.ReadLine();
double s = 0;
for (int i = 0; i < m.Length; i++)
s += double.Parse(m.Substring(i,1));
string k = Convert.ToString(s / 2);
if (k.Contains("."))
Console.WriteLine("tsifriin niilber {0}, sondgoi too",s );
else
Console.WriteLine("tsifriin niilber {0}, tegsh too", s);
Console.ReadLine();
}
}
}
 Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивын элементүүдийг хөрвүүлж b[1],b[2],b[3],… b[n] массивт хий.
namespace ConsoleApplication35
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[100];
int[] b = new int[100];
Console.Write("a massiviin elementiin too:=");
int n =int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
Console.Write("a[{0}]:=", i);
a[i] = int.Parse(Console.ReadLine());
}
int t = n;
for (int i = 1; i <= n; i++)
{
b[i] = a[t];
t--;
}
for (int i = 1; i <= n; i++)
Console.WriteLine("b[{0}]:={1}", i, b[i]);
Console.ReadLine();
}
}
}
 Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивын элементүүдийг багаас нь ихрүү өсөх дарааллаар эрэмбэл.
namespace ConsoleApplication36
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[100];
Console.Write("a massiviin elementiin too:=");
int n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
Console.Write("a[{0}]:=", i);
a[i] = int.Parse(Console.ReadLine());
}
int k=0;
for (int i = 1; i < n; i++)
for (int j = i+1; j <= n; j++)
if (a[i] > a[j])
{
k = a[i];
a[i] = a[j];
a[j] = k;
}
for (int i = 1; i <= n; i++)
Console.WriteLine("a[{0}]:={1}", i, a[i]);
Console.ReadLine();
}
}
}
 Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массиваас хамгийн их утгыг ол.
namespace ConsoleApplication37
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[100];
Console.Write("a massiviin elementiin too:=");
int n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
Console.Write("a[{0}]:=", i);
a[i] = int.Parse(Console.ReadLine());
}
int max = a[1];
for (int i = 2; i <= n; i++)
if (max < a[i])
max = a[i];
Console.WriteLine("hamgiin ih utga n: {0} ", max);
Console.ReadLine();
}
}
}
 Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивт хамгийн их элемент хаана байгааг ол.
namespace ConsoleApplication37
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[100];
Console.Write("a massiviin elementiin too:=");
int n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
Console.Write("a[{0}]:=", i);
a[i] = int.Parse(Console.ReadLine());
}
int max = a[1];
int j=1;
for (int i = 2; i <= n; i++)
if (max < a[i])
{
max = a[i];
j = i;
}
Console.WriteLine("hamgiin ih utga n: a[{0}]={1}", j, max);
Console.ReadLine();
}
}
}
 Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивт m тоо хэдэн ширхэг байгааг тоол.
namespace ConsoleApplication39
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[100];
Console.Write("a massiviin elementiin too:=");
int n = int.Parse(Console.ReadLine());
Console.Write("tentsuu too:=");
int m = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
Console.Write("a[{0}]:=", i);
a[i] = int.Parse(Console.ReadLine());
}
int t=0;
for (int i = 1; i <= n; i++)
if (a[i] == m)
t++;
Console.WriteLine("{0} too {1} shirheg bn,",m,t);
Console.ReadLine();
}
}
}
 Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивт хамгийн их элемент хаана хаана, хэдэн ширхэг байгааг тодорхойл.
namespace ConsoleApplication37
{
class Program
{
static void Main(string[] args)
{
int[] a = new int[100];
Console.Write("a massiviin elementiin too:=");
int n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++)
{
Console.Write("a[{0}]:=", i);
a[i] = int.Parse(Console.ReadLine());
}
int max = a[1];
for (int i = 2; i <= n; i++)
if (max < a[i])
max = a[i];
Console.WriteLine("hamgiin ih utga n: {0} ", max);
int t = 0;
for (int i = 1; i <= n; i++)
if (max == a[i])
{
t++;
Console.WriteLine("a[{0}] ", i);
}
Console.WriteLine(" {0} shirheg bn. ", t);
Console.ReadLine();
}
}
}
namespace ConsoleApplication41
{
class Program
{
static void Main(string[] args)
{
Console.Write("Ortsnii toog oruul= ");
int orts = int.Parse(Console.ReadLine());
Console.Write("Davhariin toog oruul= ");
int Floor = int.Parse(Console.ReadLine());
Console.Write("Haalagnii dugaar oruul= ");
int DoorNumber = int.Parse(Console.ReadLine());
int t = 1;
for (int i=1; i<=orts; i++)
for (int j=1; j<=Floor; j++)
for (int l = 1; l <= 3; l++)
{
if (DoorNumber == t)
switch (l)
{
case 1:
Console.WriteLine("{0}-r orts, {1}-r Davhar, zuun haalga.", i, j, l);
break;
case 2:
Console.WriteLine("{0}-r orts, {1}-r Davhar, goliin haalga.", i, j, l);
break;
case 3:
Console.WriteLine("{0}-r orts, {1}-r Davhar, baruun haalga.", i, j, l);
break;
}
t++;
}
Console.ReadLine();
}
}
}

Weitere ähnliche Inhalte

Was ist angesagt?

Novatadas en java
Novatadas en javaNovatadas en java
Novatadas en javawmca28
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]Eleanor McHugh
 
Void numero
Void numeroVoid numero
Void numeroOiga Lin
 
Tgs ppt alpro no.3
Tgs ppt alpro no.3Tgs ppt alpro no.3
Tgs ppt alpro no.31300018047
 
Media12132
Media12132Media12132
Media12132htmrk
 
exercise of basic computer programming.docx
exercise of basic computer programming.docxexercise of basic computer programming.docx
exercise of basic computer programming.docxmiftah88
 
Tablas hash (Rubén Ndong Obiang)
Tablas hash (Rubén Ndong Obiang)Tablas hash (Rubén Ndong Obiang)
Tablas hash (Rubén Ndong Obiang)edi.euitio
 

Was ist angesagt? (11)

Novatadas en java
Novatadas en javaNovatadas en java
Novatadas en java
 
Algoritmos (Moda, Redondear)
Algoritmos (Moda, Redondear)Algoritmos (Moda, Redondear)
Algoritmos (Moda, Redondear)
 
An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]An introduction to functional programming with Go [redux]
An introduction to functional programming with Go [redux]
 
Void numero
Void numeroVoid numero
Void numero
 
Prueba de montecarlo
Prueba de montecarloPrueba de montecarlo
Prueba de montecarlo
 
Tgs ppt alpro no.3
Tgs ppt alpro no.3Tgs ppt alpro no.3
Tgs ppt alpro no.3
 
Media12132
Media12132Media12132
Media12132
 
exercise of basic computer programming.docx
exercise of basic computer programming.docxexercise of basic computer programming.docx
exercise of basic computer programming.docx
 
Selection
SelectionSelection
Selection
 
Oop lect 10
Oop lect   10Oop lect   10
Oop lect 10
 
Tablas hash (Rubén Ndong Obiang)
Tablas hash (Rubén Ndong Obiang)Tablas hash (Rubén Ndong Obiang)
Tablas hash (Rubén Ndong Obiang)
 

Andere mochten auch

Давталттай алгоритмын бодлогууд
Давталттай алгоритмын бодлогуудДавталттай алгоритмын бодлогууд
Давталттай алгоритмын бодлогуудБаярсайхан Л
 
Excel ийн функцийн сан
Excel ийн функцийн санExcel ийн функцийн сан
Excel ийн функцийн санSkhaan Battulga
 
Excel function
Excel functionExcel function
Excel functionOnon Tuul
 
Салаалсан алгоритмын бодлогууд
Салаалсан алгоритмын бодлогуудСалаалсан алгоритмын бодлогууд
Салаалсан алгоритмын бодлогуудБаярсайхан Л
 
Шугаман алгоритмын бодлогууд
Шугаман алгоритмын бодлогуудШугаман алгоритмын бодлогууд
Шугаман алгоритмын бодлогуудБаярсайхан Л
 
9.эрэмбэлэлтийн аргууд
9.эрэмбэлэлтийн аргууд9.эрэмбэлэлтийн аргууд
9.эрэмбэлэлтийн аргуудBayalagmaa Davaanyam
 

Andere mochten auch (7)

Давталттай алгоритмын бодлогууд
Давталттай алгоритмын бодлогуудДавталттай алгоритмын бодлогууд
Давталттай алгоритмын бодлогууд
 
Excel ийн функцийн сан
Excel ийн функцийн санExcel ийн функцийн сан
Excel ийн функцийн сан
 
Excel function
Excel functionExcel function
Excel function
 
Салаалсан алгоритмын бодлогууд
Салаалсан алгоритмын бодлогуудСалаалсан алгоритмын бодлогууд
Салаалсан алгоритмын бодлогууд
 
Шугаман алгоритмын бодлогууд
Шугаман алгоритмын бодлогуудШугаман алгоритмын бодлогууд
Шугаман алгоритмын бодлогууд
 
9.эрэмбэлэлтийн аргууд
9.эрэмбэлэлтийн аргууд9.эрэмбэлэлтийн аргууд
9.эрэмбэлэлтийн аргууд
 
Uguulbertei bodlogo
Uguulbertei bodlogoUguulbertei bodlogo
Uguulbertei bodlogo
 

Mehr von orgil

Bodlogo
BodlogoBodlogo
Bodlogoorgil
 
Its150 l3
Its150 l3Its150 l3
Its150 l3orgil
 
Its150 l2
Its150 l2Its150 l2
Its150 l2orgil
 
Its150 l1
Its150 l1Its150 l1
Its150 l1orgil
 
Test
TestTest
Testorgil
 
Example excel2007
Example excel2007Example excel2007
Example excel2007orgil
 
Test7
Test7Test7
Test7orgil
 
Test6
Test6Test6
Test6orgil
 
Bodlogiin code
Bodlogiin codeBodlogiin code
Bodlogiin codeorgil
 
Its150 l10powerpoint2007
Its150 l10powerpoint2007Its150 l10powerpoint2007
Its150 l10powerpoint2007orgil
 
Its150 l10powerpoint2007
Its150 l10powerpoint2007Its150 l10powerpoint2007
Its150 l10powerpoint2007orgil
 
Test5
Test5Test5
Test5orgil
 
Test7
Test7Test7
Test7orgil
 
Test7
Test7Test7
Test7orgil
 
Test7
Test7Test7
Test7orgil
 
Test7
Test7Test7
Test7orgil
 
Test6
Test6Test6
Test6orgil
 
Test4
Test4Test4
Test4orgil
 
Test3
Test3Test3
Test3orgil
 

Mehr von orgil (20)

Bodlogo
BodlogoBodlogo
Bodlogo
 
Its150 l3
Its150 l3Its150 l3
Its150 l3
 
Its150 l2
Its150 l2Its150 l2
Its150 l2
 
Its150 l1
Its150 l1Its150 l1
Its150 l1
 
Bd
BdBd
Bd
 
Test
TestTest
Test
 
Example excel2007
Example excel2007Example excel2007
Example excel2007
 
Test7
Test7Test7
Test7
 
Test6
Test6Test6
Test6
 
Bodlogiin code
Bodlogiin codeBodlogiin code
Bodlogiin code
 
Its150 l10powerpoint2007
Its150 l10powerpoint2007Its150 l10powerpoint2007
Its150 l10powerpoint2007
 
Its150 l10powerpoint2007
Its150 l10powerpoint2007Its150 l10powerpoint2007
Its150 l10powerpoint2007
 
Test5
Test5Test5
Test5
 
Test7
Test7Test7
Test7
 
Test7
Test7Test7
Test7
 
Test7
Test7Test7
Test7
 
Test7
Test7Test7
Test7
 
Test6
Test6Test6
Test6
 
Test4
Test4Test4
Test4
 
Test3
Test3Test3
Test3
 

Bodlogo

  • 1. namespace ConsoleApplication15 { class Program { static void Main(string[] args) { Console.Write("a too: "); int a = int.Parse(Console.ReadLine()); Console.Write("b too: "); int b = int.Parse(Console.ReadLine()); Console.Write("c too: "); int c = int.Parse(Console.ReadLine()); if (a > b) if (b > c) Console.WriteLine("min: c too {0}", c); else Console.WriteLine("min: b too {0}", b); else if (a>c) Console.WriteLine("min: c too {0}", c); else Console.WriteLine("min: a too {0}", a); Console.ReadLine(); } } } namespace ConsoleApplication17 { class Program { static void Main(string[] args) { Console.Write("age: "); int a = int.Parse(Console.ReadLine()); Console.WriteLine("sex: "); string k = Console.ReadLine(); if ((a >= 18) && ( k == "er")) Console.Write("tseregt yvj bolno"); else Console.Write("tseregt yvj bolohgui"); Console.ReadLine();
  • 2. } } } namespace ConsoleApplication18 { class Program { static void Main(string[] args) { int s = 1; Console.Write("n!: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) s *= i; Console.WriteLine(s); Console.ReadLine(); } } } namespace ConsoleApplication23 { class Program { static void Main(string[] args) { Console.WriteLine("N ширхэг тооны нийлбэр олох"); Console.Write("N тоог оруулна уу: "); int n=int.Parse(Console.ReadLine()); int s = 0; for (int i = 1; i <= n; i++) { Console.Write("{0}-р тоог оруулна уу: ", i); s += (int.Parse(Console.ReadLine())); } Console.WriteLine("{0} ширхэг тооны нийлбэр: {1} ",n,s); Console.ReadLine(); }
  • 3. } } namespace ConsoleApplication25 { class Program { static void Main(string[] args) { string[] temdegtmassiv; temdegtmassiv = new string[100]; Console.WriteLine("neg hemjeest massiviin gishuudiig oruul: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.Write("{0}-r gishuunii utga oruulna uu: ", i); temdegtmassiv[i] = Console.ReadLine(); } foreach (string s in temdegtmassiv) Console.Write(s); Console.ReadLine(); } } } namespace ConsoleApplication26 { class Program { static void Main(string[] args) { int[] massivA = new int[100]; Console.WriteLine("neg hemjeest massiviin gishuudiig oruul: "); int n = int.Parse(Console.ReadLine()); int s=0; for (int i = 1; i <= n; i++) { Console.Write("{0}-r gishuunii utga oruulna uu: ", i); massivA[i] = int.Parse(Console.ReadLine()); s += massivA[i];
  • 4. } Console.Write("niilber{0}",s); Console.ReadLine(); } } }  Өгөгдсөн тоог хөрвүүлэх namespace ConsoleApplication32 { class Program { static void Main(string[] args) { string s = Console.ReadLine(); string k = ""; int j = s.Length-1; for (int i = 0; i < s.Length; i++) { k=k.Insert(i,s.Substring(j, 1)); j--; } Console.WriteLine(k); Console.ReadLine(); } } }  Өгөгдсөн тоо палиндром тоо эсэх namespace ConsoleApplication32 { class Program { static void Main(string[] args) { string s = Console.ReadLine(); string k = ""; int j = s.Length-1;
  • 5. for (int i = 0; i < s.Length; i++) { k=k.Insert(i,s.Substring(j, 1)); j--; } if (int.Parse(s) == int.Parse(k)) Console.WriteLine("palindrom mon"); else Console.WriteLine("palindrom bish"); Console.ReadLine(); } } }  Өгөгдсөн тоо тэгш эсвэл сондгой эсэхийг тодорхойлох namespace ConsoleApplication34 { class Program { static void Main(string[] args) { double m = double.Parse(Console.ReadLine()); string s=Convert.ToString(m/2); if (s.Contains(".")) Console.WriteLine("sondgoi"); else Console.WriteLine("tegsh"); Console.ReadLine(); } } }  Өгөгдсөн тооны цифрийн нийлбэр тэгш эсвэл сондгой эсэхийг тодорхойлох namespace ConsoleApplication40 {
  • 6. class Program { static void Main(string[] args) { Console.Write("too oruul="); string m = Console.ReadLine(); double s = 0; for (int i = 0; i < m.Length; i++) s += double.Parse(m.Substring(i,1)); string k = Convert.ToString(s / 2); if (k.Contains(".")) Console.WriteLine("tsifriin niilber {0}, sondgoi too",s ); else Console.WriteLine("tsifriin niilber {0}, tegsh too", s); Console.ReadLine(); } } }  Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивын элементүүдийг хөрвүүлж b[1],b[2],b[3],… b[n] массивт хий. namespace ConsoleApplication35 { class Program { static void Main(string[] args) { int[] a = new int[100]; int[] b = new int[100]; Console.Write("a massiviin elementiin too:="); int n =int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.Write("a[{0}]:=", i); a[i] = int.Parse(Console.ReadLine()); } int t = n; for (int i = 1; i <= n; i++) {
  • 7. b[i] = a[t]; t--; } for (int i = 1; i <= n; i++) Console.WriteLine("b[{0}]:={1}", i, b[i]); Console.ReadLine(); } } }  Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивын элементүүдийг багаас нь ихрүү өсөх дарааллаар эрэмбэл. namespace ConsoleApplication36 { class Program { static void Main(string[] args) { int[] a = new int[100]; Console.Write("a massiviin elementiin too:="); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.Write("a[{0}]:=", i); a[i] = int.Parse(Console.ReadLine()); } int k=0; for (int i = 1; i < n; i++) for (int j = i+1; j <= n; j++) if (a[i] > a[j]) { k = a[i]; a[i] = a[j]; a[j] = k; }
  • 8. for (int i = 1; i <= n; i++) Console.WriteLine("a[{0}]:={1}", i, a[i]); Console.ReadLine(); } } }  Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массиваас хамгийн их утгыг ол. namespace ConsoleApplication37 { class Program { static void Main(string[] args) { int[] a = new int[100]; Console.Write("a massiviin elementiin too:="); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.Write("a[{0}]:=", i); a[i] = int.Parse(Console.ReadLine()); } int max = a[1]; for (int i = 2; i <= n; i++) if (max < a[i]) max = a[i]; Console.WriteLine("hamgiin ih utga n: {0} ", max); Console.ReadLine(); } } }  Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивт хамгийн их элемент хаана байгааг ол. namespace ConsoleApplication37
  • 9. { class Program { static void Main(string[] args) { int[] a = new int[100]; Console.Write("a massiviin elementiin too:="); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.Write("a[{0}]:=", i); a[i] = int.Parse(Console.ReadLine()); } int max = a[1]; int j=1; for (int i = 2; i <= n; i++) if (max < a[i]) { max = a[i]; j = i; } Console.WriteLine("hamgiin ih utga n: a[{0}]={1}", j, max); Console.ReadLine(); } } }  Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивт m тоо хэдэн ширхэг байгааг тоол. namespace ConsoleApplication39 { class Program { static void Main(string[] args) { int[] a = new int[100]; Console.Write("a massiviin elementiin too:="); int n = int.Parse(Console.ReadLine());
  • 10. Console.Write("tentsuu too:="); int m = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.Write("a[{0}]:=", i); a[i] = int.Parse(Console.ReadLine()); } int t=0; for (int i = 1; i <= n; i++) if (a[i] == m) t++; Console.WriteLine("{0} too {1} shirheg bn,",m,t); Console.ReadLine(); } } }  Өгөгдсөн a[1],a[2],a[3],… a[n] нэг хэмжээст массивт хамгийн их элемент хаана хаана, хэдэн ширхэг байгааг тодорхойл. namespace ConsoleApplication37 { class Program { static void Main(string[] args) { int[] a = new int[100]; Console.Write("a massiviin elementiin too:="); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.Write("a[{0}]:=", i); a[i] = int.Parse(Console.ReadLine()); } int max = a[1]; for (int i = 2; i <= n; i++)
  • 11. if (max < a[i]) max = a[i]; Console.WriteLine("hamgiin ih utga n: {0} ", max); int t = 0; for (int i = 1; i <= n; i++) if (max == a[i]) { t++; Console.WriteLine("a[{0}] ", i); } Console.WriteLine(" {0} shirheg bn. ", t); Console.ReadLine(); } } } namespace ConsoleApplication41 { class Program { static void Main(string[] args) { Console.Write("Ortsnii toog oruul= "); int orts = int.Parse(Console.ReadLine()); Console.Write("Davhariin toog oruul= "); int Floor = int.Parse(Console.ReadLine()); Console.Write("Haalagnii dugaar oruul= "); int DoorNumber = int.Parse(Console.ReadLine()); int t = 1; for (int i=1; i<=orts; i++) for (int j=1; j<=Floor; j++) for (int l = 1; l <= 3; l++) { if (DoorNumber == t) switch (l) { case 1:
  • 12. Console.WriteLine("{0}-r orts, {1}-r Davhar, zuun haalga.", i, j, l); break; case 2: Console.WriteLine("{0}-r orts, {1}-r Davhar, goliin haalga.", i, j, l); break; case 3: Console.WriteLine("{0}-r orts, {1}-r Davhar, baruun haalga.", i, j, l); break; } t++; } Console.ReadLine(); } } }