2020/03 4

윈도우 10의 PowerShell 에서 행렬 곱셈 계산하기

VisualStudio 2019 의 메뉴에서 "도구(T)" -> "명령줄(L)" -> "개발자 PowerShell(P)" 을 선택하거나 윈도우 10에서 '윈도우 키' + 'R' 을 누른 다음 명령어 입력 난에 powershell 을 입력하여 나타난 PowerShell 창에서 다음을 입력한다. function multarrays($a, $b) { $n,$m,$p = ($a.Count - 1), ($b.Count - 1), ($b[0].Count - 1) if ($a[0].Count -ne $b.Count) {throw "Multiplication impossible"} $c = @(0)*($a[0].Count) foreach ($i in 0..$n) { $c[$i] = foreach ($j in 0..$p..

C# 의 세제곱근 구하는 함수 Cbrt()

C 언어나 C++ 언어에는 세제곱근을 구하는 함수 cbrt() 가 기본적으로 제공되어 있다. 소스에서 단지 #include 또는 #include 를 추가하기만 된다. 그러나 C# 언어에는 이런 함수가 기본적으로 제공되지 있지 않다. (Framework 의 경우) 그런데 Core 3.0 이상의 경우에는 C# 언어에서도 제곱근 함수 Sqrt() 와 세제곱근 함수 Cbrt() 를 기본적으로 사용할 수 있다. using System.Math; 구문이 없더라도 쓸 수 있다. Visual Studion 2019에서 "새 프로젝트 만들기" -> "콘솔 앱(.NET Core)" 하고 프로젝트 이름을 적당히 써 주고 C# 소스 Progam.cs 를 편집하는 창에서 Main() 함수 부분을 다음과 같이 수정하고 빌드하여 ..

프로그래밍/C# 2020.03.25

오일러 프로젝트 문제 9를 푸는 매우 간단한 C# 소스

참고: Special Pythagorean triplet Problem 9 아래는 문제 해결에 도움되는 유효한 (정수론의 어떠헌) 정리도 사용하지 않고, 단순히 중첩된 for 반복문을 사용한 (이해하기 쉬운) C# 소스와 그 실행 결과이다. C# 소스: // Filename: PainSolutionEulerProjectNum9.cs // // Compile: csc PainSolutionEulerProjectNum9.cs // // Execute: PainSolutionEulerProjectNum9 // // See: https://projecteuler.net/problem=9 using System; namespace GeneralCommandLineApp { class Program { static..

카테고리 없음 2020.03.05

원시 피타고라스 삼조를 생성하는 C# 소스

원시 피타고라스 삼조(primitive pythagorea triplet)를 생성하는 명령줄 어플(Command Line Application) C# 소스 C# 소스: // Filename: GeneratePrimitivePythagoreanTriplets.cs // // Compile: csc GeneratePrimitivePythagoreanTriplets.cs // // Execute: GeneratePrimitivePythagoreanTriplets 7 using System; using System.Collections.Generic; namespace GeneralCommandLineApp { class Program { public static Int64 GetGCD(Int64 xa, Int..

프로그래밍/C# 2020.03.01