본문 바로가기
728x90

알고리즘3

[알고리즘] 재귀함수 재귀함수의 대표적인 예 팩토리얼과 피보나치수열로 재귀함수를 연습하였다. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace reflexive { class Program { static void Main() { int input = 5; int factorial = Factorial(input); Console.WriteLine("{0}! = {1}", input, factorial); int fibpnacci = FibonacciN(input); Console.WriteLine("{0}번째 항 : {1}", input, fibpna.. 2023. 2. 8.
[BOJ C#] 4796 캠핑 처음에 쉬워보여서 구조 자체는 빨리 짰지만 함정이 있던 문제. +오타, \n 조심 using System; using System.Text; using System.IO; namespace _4796 { class Program { static void Main() { StreamReader sr = new StreamReader(Console.OpenStandardInput()); StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()); StringBuilder sb = new StringBuilder(); int caseN = 0; int result = 0; while (true) { if (caseN > 0) { sb.AppendForm.. 2023. 2. 1.
[C# 알고리즘] 무방향 그래프 2차원 배열로 구현하기 1: 서울 2: 대구 3: 대전 4: 부산 가중치 x using System; using System.Linq; namespace Graph { class Node { public string data; public Node(string data) { this.data = data; } } class Graph { private Node[] nodes; int[,] maps; public Graph(int n) { this.nodes = new Node[n]; maps = new int[n+1, n+1]; } public void AddVertex(Node node) { this.nodes.Append(node); } public void AddEdge(int n0, int n1) { maps[n0, n.. 2023. 1. 30.
728x90