본문 바로가기

프로그래밍

(75)
BMI_Clinic - 기본 코드 using System; namespace BMI_Clinic { enum Diagnosis { Low, Normal, Over, Fat, High_Fat } class Program { static void Main(string[] args) { int n; //고객 수 string name; char sex; byte age; double height, weight; Console.Write("고객수를 입력해 주세요 : "); n = Convert.ToInt32(Console.ReadLine()); User[] users = new User[n]; for (int i = 0; i 0) ? value : height); } } private double weight; public double Weigh..
정처기 오답 - 정보처리기사 2020년 08월 22일 기출문제 정답률 : 80% DISTINCT : 중복 튜플 발견 시 그 중 첫번째 하나만 검색 따라서 학년 1 1 2 2 3 중 중복된 값 1과 2는 하나만 검색 = 학년 1 2 3 [해설작성자 : !]
C# 상속 Car.cs using System; using System.Collections.Generic; using System.Text; namespace ParkingManagement { class Car //설계도 { public string PlateNumber { get; } //private라는 접근제한자를 가지고 있음 -> 공개해야함 / 멤버변수 plateNumber 만듦 public bool IsSUV { get; } //get만 가능, 읽기전용 속성 set은 허락해주는 것 public DateTime InTime { get; } //몇시에 들어와서 언제 나갔나 멤버변수에 포함 public DateTime OutTime; public int Duration; // 주차시간(분) - 정수형 변수 ..
C# age = (value > 0) ? value : age; Car.cs using System; using System.Collections.Generic; using System.Text; namespace ParkingManagement { class Car //설계도 { public string PlateNumber { get; } //private라는 접근제한자를 가지고 있음 -> 공개해야함 / 멤버변수 plateNumber 만듦 public bool IsSUV { get; } //get만 가능, 읽기전용 속성 set은 허락해주는 것 public DateTime InTime { get; } //몇시에 들어와서 언제 나갔나 멤버변수에 포함 public DateTime OutTime; public int Duration; // 주차시간(분) - 정수형 변수 ..
C# List Dictionary 예제 사과 딸기 namespace test2 { class Program { static void Main(string[] args) { List fruits = new List() { "사과", "딸기", "사과", "바나나", "바나나", "포도" }; // 딕셔너리 선언 Dictionary fruitCount = new Dictionary(); foreach (var item in fruits) { if (fruitCount.ContainsKey(item)) // 과일이 fruitCount Key에 있으면 fruitCount[item]++; //과일 Key의 값++ else fruitCount.Add(item, 1); //fruitCount에 새로운 Key추가 } foreach (var item in fruitCo..
C# Dictionary 예제 최종 using System; using System.Collections.Generic; namespace test2 { class Program { static void Main(string[] args) { List list1 = new List(); //오른쪽을 왼쪽 list1 대입 List list2 = new List();//list후 tap키 누르면 string 선택됨 Dictionary parasite = new Dictionary() { {'a',"봉준호" }, {'b',"조여정" } }; parasite.Add('c', "이선균"); //새로운 요소 추가 가능 Console.WriteLine(parasite['b']); //키값이 특정한 특성을 가지고 있는 지 확인하고 싶음 /* par..
test2 list클래스 예제 최종 using System; using System.Collections.Generic; namespace test2 { class Program { static void Main(string[] args) { List list1 = new List(); //오른쪽을 왼쪽 list1 대입 List list2 = new List();//list후 tap키 누르면 string 선택됨 list1.Add(1); //비어있는 앞자리에 1이 들어간것임 int[] x = { 2, 3, 4, 5 }; list1.AddRange(x); //add는 하나씩 넣는 거 addrange는 통채로 넣는 것 list1.Insert(1, 10); //중간에 넣을 떄 insert list1.Remove(10); //item삭제 li..
C# 주차장 요금계산 시스템 using System; namespace ParkingManagement { class Program { static void Main(string[] args) //진입점 { Car car1 = new Car(); car1.plateNumber = "123가 4567"; //번호판 지정 car1.InTime = DateTime.Now; Console.WriteLine(car1.InTime); } } } using System; using System.Collections.Generic; using System.Text; namespace ParkingManagement { class Car //설계도 { public string plateNumber; //private라는 접근제한자를 가지고 있음 -..
문자열 분리 using System; using System.Linq; namespace Season { class Program { static void Main(string[] args) { string input = "감자,고구마,토마토"; //문자열 구부기호: 컴마, 공백 string[] inputs = input.Split(new char[] { ',', ' ' }); foreach (var item in inputs) { Console.WriteLine("Joined string => " + string.Join(" : ", inputs)); } } } } using System; using System.Linq; namespace Season { class Program { static void Main..
continue using System; using System.Linq; namespace Season { class Program { static void Main(string[] args) { for (int i = 1; i