Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging-and-Squashing #3

Open
nrgbatman opened this issue Apr 24, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@nrgbatman
Copy link
Owner

commented Apr 24, 2019

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

namespace Merging_and_Squashing
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());

        int[] array = new int[n];

        for (int i = 0; i < array.Length; i++)
        {
            array[i] = int.Parse(Console.ReadLine());
        }
      

        int n1 = 0;
        int n2 = 0;
        int n3 = 0;
        int sum = 0;

        int[] mergingNumbers = new int[n - 1];

        for (int y = 1; y < array.Length; y++)
        {
            n1 = ((array[y - 1]) % 10*10);
            n2 = ((array[y] / 10));

            sum = n1 + n2;
            mergingNumbers[y - 1] = sum;

        }

        int[] squashedNumbers = new int[n - 1];


        for (int q = 1; q < array.Length; q++)
        {
            n1 = array[q - 1] / 10 * 100;
            int mid = ((array[q - 1] % 10) + (array[q] / 10));

            if (mid > 10)
            {
                n2 = (mid - 10) * 10;
            }
            if (mid<10)
            {
                n2 = mid * 10;
            }
            if (mid == 10)
            {
                n2 = 0;
            }
            n3 = (array[q] % 10);
            sum = n1 + n2 + n3;


            squashedNumbers[q - 1] = sum;

        }

        foreach (int item in mergingNumbers)
        {
            Console.Write(item + " ");
        }
        Console.WriteLine();

        foreach (int item in squashedNumbers)
        {
            Console.Write(item + " ");
        }
        Console.WriteLine();








        //foreach (int item in mergingNumbers)
        //{

        //    Console.Write(item+" ");
        //}

    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.