C#/Study
1차원 배열
미고렝
2019. 9. 24. 17:41
코드:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Sample input"); //콘솔 창에 Sample input 출력
String number = Console.ReadLine(); // 사용자의 입력을 String형 number에 저장
int number2 = Convert.ToInt32(number); //String형 number를 int32로 변환하여 number2에 저장
int[] array = new int[number2]; // int형 배열 크기가 number2인 배열 array 생성
Console.WriteLine(number2); // number2값 콘솔 창에 출력
for (int i = 0; i < number2; i++)
{
String value = Console.ReadLine();
int value2 = Convert.ToInt32(value);
array[i] = value2;
}
for (int i = 0; i < number2; i++)
{
Console.WriteLine(array[i]);
}
Console.ReadLine();
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
출력: