C# 소스:

// Filename: GeneratePythagoreanTriplesn.cs
//
// Compile: csc GeneratePythagoreanTriples.cs
//
// Execute: GeneratePythagoreanTriples 40

using System;
using System.Collections.Generic;

namespace GeneralCommandLineApp
{
     class PythagorianTriple {
        Int64 a, b, c;
        public PythagorianTriple(Int64 x) {
             Int64 t;
        	if (x >1 && x % 2 == 1) {
           	    this.a = x;
            	    this.b = (x*x - 1)/2;;
           	    this.c = this.b + 1;;
        	}
        	else if (x >= 2) {
        	    t = x + 2;
            	    this.a = t;
            	    this.b = t*t/4 - 1;
           	    this.c = this.b + 2;;
           	}
       }
        public Int64 GetA() {
        	return this.a;
        }
        public Int64 GetB() {
        	return this.b;
        }
        public Int64 GetC() {
        	return this.c;
        }

        public override string ToString() {
        	return "(" + this.a + ", " + this.b + ", " + this.c + ")";
        }
    }
    
   class Program
    {
         public static void GenerateTriples(List<PythagorianTriple> data, Int64 k)
        {
    	  for (Int64 i = 1; i <= k; i++)
    	  {
    	      data.Add(new PythagorianTriple(2*i + 1));
    	      data.Add(new PythagorianTriple(2*i));
    	  }
        }

        public static void PrintTriplesAsTableForm(List<PythagorianTriple> data)
        {
    	  Int64 c = data.Count;
    	   int j;
              Console.WriteLine("Show Pythagorian triples (a, b, c) each of which satisfies a^2 + b^2 = c^2.");
              Console.WriteLine();
              Console.WriteLine("      +--------+--------+--------+         +--------+--------+--------+");
              Console.WriteLine("      |   Odd  |        |        |         |  Even  |        |        |");
              Console.WriteLine("      |     a  |     b  |     c  |         |     a  |     b  |     c  |");
              Console.WriteLine("      +--------+--------+--------+         +--------+--------+--------+");
               for (int i = 0; i < c; i += 2) {
                   Console.Write("      | {0, 6} | {1, 6} | {2, 6} |", data[i].GetA(), data[i].GetB(), data[i].GetC());
                   j = i + 1;
                   Console.WriteLine("         | {0, 6} | {1, 6} | {2, 6} |", data[j].GetA(), data[j].GetB(), data[j].GetC());
               }
              Console.WriteLine("      +--------+--------+--------+         +--------+--------+--------+");
        }


        static void Main(string[] args)
        {
        	Int64 c;
        	if (args.Length == 1) {
                c = Convert.ToInt64(args[0]);
                if (c < 1) {
                     Console.WriteLine("Sorry, you should a positive integer.");
                     return;
                }
                else {
                    List<PythagorianTriple> data = new List<PythagorianTriple>();
                    GenerateTriples(data, c);
                     PrintTriplesAsTableForm(data);
                     return;
                }
            }
            else
                Console.WriteLine("Usage:  GeneratePyThagoriaTriples  [number]");
        }
    }
}

 

 

 

 

 

실행: 프롬프트> GeneratePythagoreanTriples 40

실행 결과:

더보기

Show Pythagorian triples (a, b, c) each of which satisfies a^2 + b^2 = c^2.

+--------+--------+--------+ +--------+--------+--------+
| Odd | | | | Even | | |
| a | b | c | | a | b | c |
+--------+--------+--------+ +--------+--------+--------+
| 3 | 4 | 5 | | 4 | 3 | 5 |
| 5 | 12 | 13 | | 6 | 8 | 10 |
| 7 | 24 | 25 | | 8 | 15 | 17 |
| 9 | 40 | 41 | | 10 | 24 | 26 |
| 11 | 60 | 61 | | 12 | 35 | 37 |
| 13 | 84 | 85 | | 14 | 48 | 50 |
| 15 | 112 | 113 | | 16 | 63 | 65 |
| 17 | 144 | 145 | | 18 | 80 | 82 |
| 19 | 180 | 181 | | 20 | 99 | 101 |
| 21 | 220 | 221 | | 22 | 120 | 122 |
| 23 | 264 | 265 | | 24 | 143 | 145 |
| 25 | 312 | 313 | | 26 | 168 | 170 |
| 27 | 364 | 365 | | 28 | 195 | 197 |
| 29 | 420 | 421 | | 30 | 224 | 226 |
| 31 | 480 | 481 | | 32 | 255 | 257 |
| 33 | 544 | 545 | | 34 | 288 | 290 |
| 35 | 612 | 613 | | 36 | 323 | 325 |
| 37 | 684 | 685 | | 38 | 360 | 362 |
| 39 | 760 | 761 | | 40 | 399 | 401 |
| 41 | 840 | 841 | | 42 | 440 | 442 |
| 43 | 924 | 925 | | 44 | 483 | 485 |
| 45 | 1012 | 1013 | | 46 | 528 | 530 |
| 47 | 1104 | 1105 | | 48 | 575 | 577 |
| 49 | 1200 | 1201 | | 50 | 624 | 626 |
| 51 | 1300 | 1301 | | 52 | 675 | 677 |
| 53 | 1404 | 1405 | | 54 | 728 | 730 |
| 55 | 1512 | 1513 | | 56 | 783 | 785 |
| 57 | 1624 | 1625 | | 58 | 840 | 842 |
| 59 | 1740 | 1741 | | 60 | 899 | 901 |
| 61 | 1860 | 1861 | | 62 | 960 | 962 |
| 63 | 1984 | 1985 | | 64 | 1023 | 1025 |
| 65 | 2112 | 2113 | | 66 | 1088 | 1090 |
| 67 | 2244 | 2245 | | 68 | 1155 | 1157 |
| 69 | 2380 | 2381 | | 70 | 1224 | 1226 |
| 71 | 2520 | 2521 | | 72 | 1295 | 1297 |
| 73 | 2664 | 2665 | | 74 | 1368 | 1370 |
| 75 | 2812 | 2813 | | 76 | 1443 | 1445 |
| 77 | 2964 | 2965 | | 78 | 1520 | 1522 |
| 79 | 3120 | 3121 | | 80 | 1599 | 1601 |
| 81 | 3280 | 3281 | | 82 | 1680 | 1682 |
+--------+--------+--------+ +--------+--------+--------+

 

 

Posted by Scripter
,

한글, 일본어, 중국어를 모두 사용하는 문서를 작성하기 위해

 

한글2020을 설치하였지만, 중국어 입력은 되는데 일본어는 일본어 자판기를

 

선택만하기만 하면 한글2020의 동작이 멈추고 무한 대기 상태가 되어

 

작업관리자에서 한글2020강제 종료 해야먄 했다.

 

이 문제를 해결하고 나서 깨달은 것은 이전에 설치되어 있던 

 

한글 Office 2010 을 제거하였는데도 남아 있던 파일 hjimesv.ini 에 있던

 

내용 때문이었다. 한글 Office 2020을 설치했으면 설치 과정 중에

 

이 파일의 내용이 새로이 수정되고 자동으로 저장되어야 함에도 여전히 그대로

 

방치되어 한글 2020에서 일본어 입력을 전혀 못하다가

 

이 파일에 설정되어 있던 값을 수정하니

 

한글 2020에서 아무 문제 없이 일본어 입력을 잘 할 수 있게 되었다.

 

 

 

다음은 Right Shift + Spacebar(일본어 Hiragana 키보드)를 눌러 일본어를 입력 중인

 

화면을 캡쳐한 것이다.

 

[힌글 2020에서 일본어 하라가나 입력 중]

 

 

 

 

한글 2020에서 일본어자판을 선택하면 한글 2020이 비정상 종료하는 경우를 아래와 같이 해결하였다.

 

이전 버전의 한글 Office 2010을 사용할 때는 파일 C:\Windows\hjimesv.ini

 

에 일본어 자판기 관련 설정이 다음 처럼 되어 있었다.

 

[HncJapaneseIMEServer]
path=C:\Program Files (x86)\Hnc\Common80\him\

 

 

 

윈도우 보조프로그램 Notepad 를 관리자 실행권한으로 열어 이것의 내용을

 

아래와 같이 수정하였다. (필자의 경우 이전 버전 한글 Office 2010을 C:\ 드라이브에

 

설치되어 있었지만 새 버전 한글 Office 2020은 D:\ 드라이브에 설치하였다.

 

[HncJapaneseIMEServer]
path=D:\Program Files (x86)\HNC\Office 2020\HOffice110\Bin\Him\

 

 

위와 같이 수정된 내용을 다시 저장하고 한글 2020을 관리자 권한으로 실행하니

 

일본어 입력이 문제 없이 잘 되었다.

 

 

 

필자의 경우 자판기 설정이 다음 처럼 되어 있다.

 

(한글 2020의 메뉴에서 "도구" -> "글자판(K)" -> "글자판 바꾸기(K)" 하거나

 키보드 Alt+F2 를 클릭하면 나오는 창)

 

[자판기 설정]

 

 

키보드 Right Shift + Spacebar 를 클릭하면 일본어 하라가나 입력 글자판이 된다.

 

일본어 입력 상태에서 키보드 Right Shift + Spacebar 를 클릭하면 중국어 간체 입력 글자판이 되고,

 

중국어 입력 상태에서 키보드 Right Shift + Spacebar 를 클릭하면 일본어 히라가나 입력 글자판이 된다.

 

 

 

 

[참고 자료] https://namu.moe/w/한컴오피스%20한글

 

한컴오피스 한글

[ChineseIME]AIContext=TRUE1st Dictionary=c:\\program files (x86)\\hnc\\hoffice9\\bin\\him\\dic\\chn\\hncchn.dic2nd Dictionary=None3th Dictionary=None4th Dictionary=None5th Dictionary=None6th Dictionary=None7th Dictionary=None8th Dictionary=None9th Dictiona

namu.moe

 

Posted by Scripter
,