# ex7 by Rolm Kolm

### Snippet options

Copy snippet: For this you need a free my code stock.com 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[] a1=new ushort[n1];
Console.WriteLine("Input {0} elements in the array: ",n1);
for(i=0;i<n1;i++)
{
Console.Write("element - {0}: ",i);
}

//second array
Console.Write("Input the number of elements to be stored in the second array: ");
ushort[] a2=new ushort[n2];
Console.WriteLine("Input {0} elements in the array: ",n2);
for(i=0;i<n2;i++)
{
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:");
for(i=0;i<n1+n2;i++)
{
//m is the biggest value of the table
m=0; for(j=0;j<n1+n2;j++) m=(ushort)(m+a[j]);
for(j=0;j<n1+n2;j++)
{
if(a[j]<=p) continue;
if(m>a[j]) {m=a[j]; e=j;}
}
p=m;
//m is the minimum value
Console.Write("{0} ",m);

//duplicates
for(j=0;j<n1+n2;j++)
{
//skip e value (e for except)
if(j==e) continue;
if(m==a[j]) {Console.Write("{0} ",m); i++;}
}
}
}
}```

### Create a free my code stock.com account now.

my code stok.com 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!

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