Language/C#

    [C#] 배열 사용해보기

    [C#] 배열 사용해보기

    0. 배열(Array) 배열이란 동일한 타입의 변수를 모아놓은 데이터 집합이다. 1. 주어진 숫자 중에서 최대, 최소값 출력해보기 using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int a = 5, b = 8, c = 9, max = a, min = a; Console.WriteLine("a={0}, b={1}, c={2}", a, b, c); if (max b) min = b; if (min > c) min = c; Console.WriteLine("최대값은 {0}입니다.", max); Console.WriteLi..

    [C#] 중첩for문 사용하기

    [C#] 중첩for문 사용하기

    1. 중첩for문을 이용하여 ########## 20줄 표시하기 using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int i, e; for(e=1;e

    [C#] for문과 while 반복문 익숙해지기

    [C#] for문과 while 반복문 익숙해지기

    1. for문을 이용하여 1~10까지 출력하기 using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { for(int a=1;a

    [C#] for 문을 사용하여 구구단 출력하며 익숙해지기

    [C#] for 문을 사용하여 구구단 출력하며 익숙해지기

    using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { for(int i=0;i

    [C#] IF문과 Switch case문을 사용하여 홀수 짝수와 계절 표시하기.

    [C#] IF문과 Switch case문을 사용하여 홀수 짝수와 계절 표시하기.

    using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int a = 9; if(a%2==1) { Console.WriteLine("홀수입니다."); } if(a%2==0) { Console.WriteLine("짝수입니다."); } } } } a를 9로 선언해준 후 if문을 사용해준다. 이때 if( ) 뒤에는 ;(세미클론)이 붙지 않는다. if문 이후 명령문을 1줄만 사용하게 된다면 { }를 사용할 필요는 없지만 2줄 이상을 사용할 시에는 반드시 사용을 해주어야 하기에 1줄이라도 { }를 사용해주는 게 좋다. 코딩한 것을 디버깅을 한다면 a가 9로 되어있기에 홀수라고 출력이 된다. using System..

    [C#] C#의 기본적인 출력문과 이스케이프 시퀀스

    [C#] C#의 기본적인 출력문과 이스케이프 시퀀스

    using System; namespace ConsoleApp1 { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); //Hello World! 출력 후 줄바꿈 Console.WriteLine("a=10"); //a=10 출력 후 줄바꿈 Console.WriteLine("b=20"); //b=20 출력 후 줄바꿈 Console.Write("a+b = "); //a+b = 출력 Console.WriteLine(10 + 20); //10+20을 계산한 값 출력 후 줄바꿈 // +분만 아니라 - * / % 또한 사용이 가능하다 Console.WriteLine("Hello \tWorld"); // \t를 사용 ..