반응형

안녕하세요, 츄르 사려고 코딩하는 집사! 코집사입니다.

이번 글은 2개의 배열을 선언하고, 각 배열의 곱을 구하는 문제입니다.

 

 

1. 소스 코드

 

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

namespace Array_Multiply
{
    class Program
    {
        static void Main(string[] args)
        {
            int numArr1 = 0;
            int numArr2 = 0;

            numArr1 = Convert.ToInt32(Console.ReadLine());

            int[] arr1 = new int[numArr1];
            for(int i=0;i<numArr1;i++)
            {
                arr1[i] = Convert.ToInt32(Console.ReadLine());
            }

            numArr2 = Convert.ToInt32(Console.ReadLine());

            int[] arr2 = new int[numArr2];
            for (int i = 0; i < numArr2; i++)
            {
                arr2[i] = Convert.ToInt32(Console.ReadLine());
            }


            Console.Write("Result : [ ");
            for(int i=0;i<numArr1;i++)
            {
                for(int j=0;j<numArr2;j++)
                {
                    Console.Write(arr1[i]*arr2[j] + " ");
                }

            }
            Console.WriteLine("]");

        }
    }
}

 

2. 결과

반응형
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기