five minutes of funk
블로그
커버
위치별 글
태그 구름
방명록
관리자
글쓰기
Array
five minutes of funk
Program/C#.NET
2010/02/01 09:58,
글쓴이
web20korea
using System; namespace Ex07Array { class Program { static void Main(string[] args) { Random r = new Random(); #region 배열 선언 및 접근 //1. //int[] ar1 = new int[10]; //for (int i = 0; i < 10; i++) //{ // ar1[i] = r.Next(100, 1000); //} //for (int i = 0; i < 10; i++) //{ // Console.WriteLine("ar[{0}] = {1}", i, ar1[i]); //} //Console.WriteLine(); //Console.WriteLine(); #endregion #region 다차원 배열 //2. //int[,] ar2 = new int[5, 7]; //for (int i = 0; i < 5; i++) //{ // for (int j = 0; j < 7; j++) // { // ar2[i, j] = r.Next(100, 1000); // } //} //for (int i = 0; i < 5; i++) //{ // for (int j = 0; j < 7; j++) // { // Console.Write("{0,5}",ar2[i,j]); // } // Console.WriteLine(); //} #endregion #region 배열 초기화 ////3. //int[] ar3_1 = new int[10] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; ////int[] ar3_1 = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; ////int[] ar3_1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; //for (int i = 0; i < 10; i++) //{ // Console.Write("{0,3}",ar3_1[i]); //} //Console.WriteLine(); //int[,] ar3_2 = new int[2, 3] { {1, 2, 3}, {4, 5, 6} }; //for (int i = 0; i < 2; i++) //{ // for (int j = 0; j < 3; j++) // { // Console.Write("{0,3}",ar3_2[i,j]); // } // Console.WriteLine(); //} #endregion #region 배열 지원 메서드 / 프로퍼티 //4. //int[] ar4_1 = new int[10]; ////배열.Length : 배열 요소의 갯수를 반환 //for (int i = 0; i < ar4_1.Length; i++) //{ // ar4_1[i] = r.Next(100, 1000); //} //Console.Write("Before Sorting : "); //for (int i = 0; i < ar4_1.Length; i++) //{ // Console.Write("{0,5}",ar4_1[i]); //} //Console.WriteLine(); //Console.Write("After Sorting : "); //Array.Sort(ar4_1); //오름차순 정렬 ////Array.Reverse(ar4_1); //배열을 역순으로 재정렬 //for (int i = 0; i < ar4_1.Length; i++) //{ // Console.Write("{0,5}",ar4_1[i]); //} //Console.WriteLine(); //Console.Write("Input Number : "); //int number = int.Parse(Console.ReadLine()); //Console.WriteLine("입력된 숫자의 배열 내 위치 : {0}", Array.IndexOf(ar4_1, number)); ////요소의 위치 없으면(-1) //////////////////////////////////////////////////////// //int[,] ar4_2 = new int[2, 3]; //for (int i = 0; i < ar4_2.GetLength(0); i++) //{ // for (int j = 0; j < ar4_2.GetLength(1); j++) // { // ar4_2[i, j] = r.Next(100, 1000); // } //} //for (int i = 0; i < ar4_2.GetLength(0); i++) //{ // for (int j = 0; j < ar4_2.GetLength(1); j++) // { // Console.Write("{0,5}",ar4_2[i,j]); // } // Console.WriteLine(); //} #endregion #region 가변 배열 전달인자 //5. //TestMethod(1); //TestMethod(1, 2); //TestMethod(1,2,3,4,5,6,7,8); #endregion #region Zagged Array //6. int[][] ar6 = new int[10][]; for (int i = 0; i < ar6.Length; i++) { ar6[i] = new int[r.Next(5, 15)]; } for (int i = 0; i < ar6.Length; i++) { for (int j = 0; j < ar6[i].Length; j++) { ar6[i][j] = r.Next(100, 1000); } } for (int i = 0; i < ar6.Length; i++) { for (int j = 0; j < ar6[i].Length; j++) { Console.Write("{0,5}",ar6[i][j]); } Console.WriteLine(); } #endregion } //가변 배열 전달인자 관련 private static void TestMethod(params int[] p) { Console.WriteLine("전달인자의 갯수 : {0}",p.Length); } } }
web20korea
2010/02/01 09:58
2010/02/01 09:58
C#
트랙백 없음
|
댓글 없음
트랙백+댓글
|
트랙백
|
댓글
이 글의 트랙백 주소
http://web20korea.com/trackback/295
add
댓글 남기기
오픈아이디로 글쓰기
[
로그인
][
오픈아이디란?
]
이름/비밀번호로 글쓰기
◀ recent
|
1
|
...
5
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
13
|
...
270
|
previous ▶
그늘과 양지 객관과 주관 정적과 소음을 적당히 끌어들여서 세계와 소통할 수 있는 블로거들이 많이 생겼으면 좋겠다! - 작가 박범신
five minutes of funk - 최근 글
제 아들놈이에요 ㅋㅋㅋ
파견생활~+_+
DOKDO, This is part of Korea
메일주소가 2칸으로 나뉘어져있는 경...
메모장
쓰레기들..ㅎㄷㄷ
촐라체
흠..지남이 덕에 만들어본? 테이블 제...
2010/03
(3)
2010/02
(11)
2010/01
(12)
2009/12
(8)
2009/11
(4)
전체
(270)
i6020345
(81)
Blogs
(21)
Program
(67)
C#.NET
(17)
ASP.NET
(6)
Classic ASP
(21)
JavaScript
(8)
html
(3)
Classic Mobile
(6)
Mobile
(0)
iPhoneApps
(0)
Tools
(22)
Open Source
(2)
DMBS
(15)
web-based Tools
(1)
Utils
(4)
Project
(61)
informative
(14)
gohome
(0)
five minutes of funk - 최근 댓글
관리자만 볼 수 있는 댓글입...
비밀방문자
좋은 자료 감사합니다. ^^
지나가는 행인
헐 어디서 샀었는지 기억이.....
web20korea
이거 어디서 살 수 있나요?...
Pke
...어렵네요......글쌔요 ㅡㅡ;;
web20korea
Set rs = DBHelper.ExecSQLRe...
web20korea
대단한 사람같습니다 근데 여...
한니발
select ident_current 이렇게...
한니발
환영합니다
행복한 우리집
"인터넷 문화에 대처하는 방법은?" 이라는...
어흥이 굴에 들어와도 정신만 차리면 하나...
아시아 오픈소스
주네의 열린 소프트웨어
iPod Touch 's Sadari 체험기
iPod Life
ASP
MSSQL
web20korea
C#
관공서
ajax
.net
Q-Bert
KTF
은평구