Wednesday, April 27, 2016

Visual C# Bodlogo

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
      public  static void search(char[] W, char[] S)
        {
            int i, j, m = W.Length, n = S.Length;
            for (i=0, j=0; j<m && i<n; i++, j++)
            
                if (S[i]!= W[j]) { i++; j=0; }
                if (j==m) Console.WriteLine(" oldloo:{0} dahi bairlaalaas",i-m);
                else
                    Console.WriteLine("olsongui:");
            
        
        }
        static void Main(string[] args)
        {int opt;
                  Console.WriteLine(" Press 1 for jagsaalt 1");
                  Console.WriteLine(" Press 2 for jagsaalt 2");
                  Console.WriteLine(" Press 3 for jagsaalt 3");
                  Console.WriteLine(" Press 4 for jagsaalt 4");
                  Console.WriteLine(" Press 5 for stek 1");
                  Console.WriteLine(" Press 6 for stek 2");
                  Console.WriteLine(" Press 7 for stek 3");
                  Console.WriteLine(" Press 8 for stek 4");
                  Console.WriteLine(" Press 9 for daraalal 1");
                  Console.WriteLine(" Press 10 for daraalal 2");
                  Console.WriteLine(" Press 11 for daraalal 3");
                  Console.WriteLine(" Press 12 for daraalal 4");
                  Console.WriteLine(" Press 13 for engiin hailt 1");
                  Console.WriteLine(" Press 14 for hailt 2");
                  Console.WriteLine(" Press 15 for hailt 3");
        
              
              
            label: Console.Write(" case songo ni uu Option:"); opt = Convert.ToInt32(Console.ReadLine());
                switch (opt)
                {
                    case 1:
                        Console.WriteLine("---- jagsaalt 1----");

                        string[] s1 = new string[5] { "biology", "chemistry", "mate", "health", "drug" };
                        List<string> ar=new List<string>(s1);
                    
                       
                      foreach (string i in ar)
                      { Console.WriteLine(i); }
                      string x = Console.ReadLine();
                       Console.WriteLine("haih utga oruulna"); string a=Console.ReadLine();
                      Console.WriteLine("ustgah utga oruulna"); string  b1=Console.ReadLine();
                      Console.WriteLine("haih:{0}", ar.Contains(a));
                      Console.WriteLine("***********************");
                      Console.WriteLine("ustgsh:{0}", ar.Remove(b1));
                      foreach (string i in ar)
                       { Console.WriteLine(i);} goto label;


                    case 2:
                        Console.WriteLine("---- jagsaalt 2----");
                         string[] aStr1= new string[10];int n;
                        
                         Console.WriteLine("n masssive hemjes oruul:"); n=Convert.ToInt32(Console.ReadLine());
                           
                            for (int i5 = 0; i5 < n; i5++)
                            { Console.WriteLine(" utga oruul aStr1[" + i5 + "] =",i5);  aStr1[i5] = Console.ReadLine();}
                            for (int i5 = 0; i5 < n; i5++)
                            { Console.WriteLine("aStr1[" + i5 + "] =" + aStr1[i5]); }
                        List<string> ar1 = new List<string>(aStr1);
                            foreach (string i5 in ar1)
                            { Console.WriteLine(i5); }
                            Console.WriteLine("ehend ORUUL:"); string z1=Console.ReadLine();
                            Console.WriteLine("TUGSHULD ORUUL:"); string z=Console.ReadLine();
                            ar1.Insert(0, z1);
                            ar1.Insert(n + 1, z);
                            Console.WriteLine("***********************");
                            foreach (string i5 in ar1)
                            { Console.WriteLine(i5); }
                            Console.WriteLine("shine massive");
                            string[] b = ar1.ToArray();
                            foreach (string m in b)
                            { Console.WriteLine(m); }
                         Console.ReadLine(); goto label;

                    case 3:
                        Console.WriteLine("---- jagsaalt 3----");
                        int t; 
                         Console.WriteLine("n masssive hemjes oruul:"); t=Convert.ToInt32(Console.ReadLine());
                         int[] m1 = new int[t];
                         for (int i3 = 0; i3 < t; i3++)
                         { Console.WriteLine("m1[" + i3 + "] =", i3); m1[i3] = Convert.ToInt32(Console.ReadLine());}
                    
                         List<int> ar2 = new List<int>(m1);
                         foreach (int j in ar2)
                         { Console.WriteLine(j);}
                         Console.WriteLine("min element: {0}", ar2.Min());
                         Console.WriteLine("max element: {0}", ar2.Max());
                         Console.WriteLine("niilver element: {0}", ar2.Sum());
                         Console.ReadLine(); goto label;
                    case 4:
                        Console.WriteLine("---- jagsaalt 4----");
                         int t1,g; 
                         Console.WriteLine("n masssive hemjes oruul:"); t1=Convert.ToInt32(Console.ReadLine());
                         int[] m2 = new int[t1];
                         for (int i4 = 0; i4 < t1; i4++)
                         { Console.WriteLine("m2[" + i4 + "] =", i4); m2[i4] = Convert.ToInt32(Console.ReadLine());}
                    
                         List<int> ar3 = new List<int>(m2);
                         foreach (int j in ar3)
                         { Console.WriteLine(j);}
                        Console.WriteLine("utga oruul:");
                         g = Convert.ToInt32(Console.ReadLine());
                         Console.WriteLine("Haih :{0}", ar3.Contains(g));
                         Console.WriteLine("ustgah :{0}", ar3.Remove(g));
                         Console.WriteLine("hemjee:{0}", ar3.Capacity);
                          Console.ReadLine(); goto label;
                    case 5:
                         Console.WriteLine("---- stek 1----");
                         int t2; 
                         Console.WriteLine("n masssive hemjes oruul:"); t2=Convert.ToInt32(Console.ReadLine());
                         int[] m3 = new int[t2];
                         for (int i4 = 0; i4 < t2; i4++)
                         { Console.WriteLine("m3[" + i4 + "] =", i4); m3[i4] = Convert.ToInt32(Console.ReadLine());}
                         Console.WriteLine(" stek mass element oruulna:");
                         Stack<int> ar4 = new Stack<int>(m3);
                         
                         foreach (int i4 in ar4)
                         { Console.WriteLine(i4); }
                         Console.WriteLine(" hooson elemt avan ,avsan elementee butsaah elemtee bairluulah");
                         for (int i4 = 0; i4 < t2; i4++)
                         { ar4.Pop(); ar4.Push(5); }
                         foreach (int i4 in ar4)
                         { Console.WriteLine(i4); }

                         Console.ReadLine(); goto label;
                    case 6:
                        Console.WriteLine("---- stek 2----");
                         int[] m4 = new int[5];
                         for (int i5 = 0; i5 < 5; i5++)
                         { Console.WriteLine("m4[" + i5 + "] =", i5); m4[i5] = Convert.ToInt32(Console.ReadLine());}

                        Console.WriteLine(" stek mass element oruulna:");
                         Stack<int> ar5 = new Stack<int>(m4);
                         
                         foreach (int i5 in ar5)
                         { Console.WriteLine(i5); }
                         Console.WriteLine("min element: {0}", ar5.Min());
                         Console.WriteLine("max element: {0}", ar5.Max());
                         Console.WriteLine("niilver element: {0}", ar5.Sum());
                         Console.ReadLine(); goto label;
                    case 7:
                        Console.WriteLine("---- stek 3----");
                        string[] s7 = new string[6] { "Public", "health", "problems", "caused", "environmental", "contamination" };
                        Stack<string> ar7 = new Stack<string>(s7);
                        foreach (string i in ar7)
                        { Console.WriteLine(i); }
                        Console.WriteLine("garaas utga oruul:"); string g5=Console.ReadLine();
                        Console.WriteLine("Haih :{0}", ar7.Contains(g5)); 
                        Console.ReadLine(); goto label;
                    case 8:
                        Console.WriteLine("---- stek 4----");
                         string[] s8= new string[10];int n1;
                        
                         Console.WriteLine("n masssive hemjes oruul:"); n1=Convert.ToInt32(Console.ReadLine());
                           
                            for (int i8 = 0; i8 < n1; i8++)
                            { Console.WriteLine(" utga oruul aStr1[" + i8 + "] =",i8); s8[i8] = Console.ReadLine();}
                            Console.WriteLine(" shine massive uusgev:");
                            for (int i8 = 0; i8 < n1; i8++)
                            { Console.WriteLine("aStr1[" + i8 + "] =" + s8[i8]); }
                          Console.WriteLine("stack massive uusgev:");
                            Stack<string> ar8 = new Stack<string>(s8);
                            foreach (string i8 in ar8)
                            { Console.WriteLine(i8); }
                            Console.WriteLine(" shine ToArray hurvuulev :");
                        string[] ss8=ar8.ToArray();
                        foreach (string ii in ss8)
                        { Console.WriteLine(ii); }
                        Console.WriteLine("new stack  uusgen huulav:");
                        Stack<string> arr8 = new Stack<string>(ss8);
                        foreach (string tt in arr8)
                        { Console.WriteLine(tt); }
                       Console.ReadLine(); goto label;
                    case 9:
                        Console.WriteLine("---- daraalal 1----");
                        string[] s9 = new string[10]; int n2;

                        Console.WriteLine("n masssive hemjes oruul:"); n2 = Convert.ToInt32(Console.ReadLine());

                        for (int i9 = 0; i9 < n2; i9++)
                        { Console.WriteLine(" utga oruul aStr1[" + i9 + "] =", i9); s9[i9] = Console.ReadLine(); }
                        Console.WriteLine(" shine massive uusgev:");
                        for (int i9 = 0; i9 < n2; i9++)
                        { Console.WriteLine("s9[" + i9 + "] =" + s9[i9]); }
                         Console.WriteLine("daraalal uusgev:");
                            Queue<string> Q1 = new Queue<string>(s9);
                            foreach (string i8 in Q1)
                            { Console.WriteLine(i8); }
                      Console.WriteLine("GARAAS UTGA ORUUL:"); string z9=Console.ReadLine();
                      Console.WriteLine("Haih :{0}", Q1.Contains(z9));
                        Console.ReadLine(); goto label;
                case 10:
                        Console.WriteLine("---- daraalal 2 ----");
                         string[] s10= new string[10];int n4;
                        
                         Console.WriteLine("n masssive hemjes oruul:"); n4=Convert.ToInt32(Console.ReadLine());
                           
                            for (int i10 = 0; i10 < n4; i10++)
                            { Console.WriteLine(" utga oruul aStr1[" + i10 + "] =",i10); s10[i10] = Console.ReadLine();}
                            Console.WriteLine(" shine massive uusgev:");
                            for (int i10 = 0; i10 < n4; i10++)
                            { Console.WriteLine("aStr1[" + i10 + "] =" + s10[i10]); }
                          Console.WriteLine("daraalal uusgev:");
                           
                         Queue<string>   Q2= new Queue<string>(s10);
                            foreach (string i8 in Q2)
                            { Console.WriteLine(i8); }
                            Console.WriteLine(" shine ToArray hurvuulev :");
                        string[] ss10= Q2.ToArray();
                     
                     
                      
                        foreach (string ii in ss10)
                        { Console.WriteLine(ii); }
                        Console.WriteLine("new daraalal uusgen huulav:");
                        Queue<string> Q21 = new Queue<string>(ss10);
                        foreach (string tt in Q21)
                        { Console.WriteLine(tt); }
                       Console.ReadLine(); goto label;
                case 11:
                    Console.WriteLine("---- daraalal 3 ----");

                         int k; 
                         Console.WriteLine("n masssive hemjes oruul:"); k=Convert.ToInt32(Console.ReadLine());
                         int[] m10 = new int[k];
                         for (int i10 = 0; i10 < k; i10++)
                         { Console.WriteLine(" int turliin too m10[" + i10 + "] =", i10); m10[i10] = Convert.ToInt32(Console.ReadLine());}
                         Console.WriteLine(" daraalal mass element oruulna:");
                        Queue<int> Q4 = new Queue<int>(m10);
                         foreach (int i4 in Q4)
                         { Console.WriteLine(i4); }
                         Console.WriteLine(" daraalal ustgana element oruulna:");
                         for (int i10 = 0; i10 < k; i10++)
                         { Q4.Clear(); }
                         for (int i10 = 0; i10 < k; i10++)
                         { Console.WriteLine(" int turliin too m10[" + i10 + "] =", i10); m10[i10] = Convert.ToInt32(Console.ReadLine()); }
                         for (int i10 = 0; i10 < k; i10++)
                         { Console.WriteLine("m10[" + i10 + "] =" + m10[i10]); }

                          Console.ReadLine(); goto label;
                case 12:
                    Console.WriteLine("---- daraalal 4 ----");
                        
                         int k1; 
                         Console.WriteLine("n masssive hemjes oruul:"); k1=Convert.ToInt32(Console.ReadLine());
                         int[] m11 = new int[k1];
                         for (int i11 = 0; i11 < k1; i11++)
                         { Console.WriteLine(" int turliin too m11[" + i11 + "] =", i11); m11[i11] = Convert.ToInt32(Console.ReadLine());}
                         Console.WriteLine(" daraalal mass element oruulna:");
                        Queue<int> Q5 = new Queue<int>(m11);
                         foreach (int i4 in Q5)
                         { Console.WriteLine(i4); }
                         Console.WriteLine(" daraalal neg element av:");
                         string d1 = Console.ReadLine();
                       

                     Console.ReadLine(); goto label;

                case 13:
                    Console.WriteLine("---- hailt  engiin 1 ----");
                    string text = "Health science";
                    string pat = "Health";
                    Console.WriteLine(text);
                    Console.WriteLine(pat);
                    char[] W= pat.ToCharArray();
                    char[] S = text.ToCharArray();
                    search(W, S);

                         Console.ReadLine(); goto label;
                   case 15:
                                Console.WriteLine("---- haSH  hayaglalt 3 ----");
            string[] ast1 = new string[11];
            string[] ast2 = new string[5];
            Int64 h, i2, mod,c;
            for (int i1 =0;i1 <ast1.Length; i1++)
            {
            Console.Write("enter strings:");
                ast1[i1]=Console.ReadLine();
                char[] c1=ast1[i1].ToCharArray();
                //h=0; mod=0;
                for (h=0, i2=0; i2<c1.Length; i2++)
                { h=(32* h + (c1[i2] -64));}
                mod =h%11;
                Console.WriteLine("hasj value: {0}",Convert.ToInt32(mod));
                for (int i=0;i<ast2.Length; i++)
                {
                    if(i==mod)
                    {
                       k:if (ast2[i] == null)
                    { Console.WriteLine("Array;{0},{1}", i,ast2[i]=ast1[i]); }
                  else {i++; goto k;}
 
                    }

                }
                   Console.WriteLine("");

                  }
           
   
Console.WriteLine("search");
                    string search1=Convert.ToString(Console.ReadLine());
                    c=0;
                    for (int i=0; i<ast2.Length; i++)
                    { if (ast2[i] == search1) {c++;} }
                    if (c==0)
                    { Console.WriteLine("oldsongvi");}
                        else
                        { Console.WriteLine("oldson"); }
                                 Console.ReadLine(); goto label;

                    default: Console.WriteLine(" \n DAHIN SONGOLTOO HIINE UU."); goto label;
                        
                }
                Console.ReadLine();
        }
    }
}