my code

Snippet options

Download: Download snippet as ex7.cpp.
Copy snippet: For this you need a free my code account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

using System;  
public class Exercise1  
    public static void Main()  
    ushort i=0;
    //first array
    Console.Write("Input the number of elements to be stored in the first array: ");
    ushort n1=Convert.ToUInt16(Console.ReadLine());
    ushort[] a1=new ushort[n1];
    Console.WriteLine("Input {0} elements in the array: ",n1);
        Console.Write("element - {0}: ",i);

    //second array
    Console.Write("Input the number of elements to be stored in the second array: ");
    ushort n2=Convert.ToUInt16(Console.ReadLine());
    ushort[] a2=new ushort[n2];
    Console.WriteLine("Input {0} elements in the array: ",n2);
        Console.Write("element - {0}: ",i);

    //merged array
    ushort[] a=new ushort[n1+n2];
    for(i=0;i<n1;i++) a[i]=a1[i];
    for(i=0;i<n2;i++) a[i+n1]=a2[i];
    ushort j=0,m=0,e=0;
    //p is the smallest value of the table
    int p=0; for(i=0;i<n1+n2;i++) p-=a[i];

    Console.WriteLine("\nThe merged array in ascending order is:");
        //m is the biggest value of the table
        m=0; for(j=0;j<n1+n2;j++) m=(ushort)(m+a[j]);
            if(a[j]<=p) continue;
            if(m>a[j]) {m=a[j]; e=j;}
        //m is the minimum value
        Console.Write("{0} ",m);
            //skip e value (e for except)
            if(j==e) continue;
            if(m==a[j]) {Console.Write("{0} ",m); i++;}

Create a free my code account now.

my code is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.