프로그래밍 605

이진 파일을 읽어서 16진수로 보여주는 HexView 소스 with Groovy

Groovy 언어 소스: // Filename: testHexView_03.groovy // // Execute: groovy testHexView_03.groovy [filename] // // Date: 2013. 7. 28. import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class TestHexView_03 { public static void printUsage() { System.out.println("groovy testHexView_03.groovy [filename]"); } public static String toHex(byte b) { String s = ""; int x1,..

이진 파일을 읽어서 16진수로 보여주는 HexView 소스 with Java

Java 언어 소스: // Filename: TestHexView03.java // // Compile: javac TestHexView03.java // Execute: java TestHexView03 [filename] // // Date: 2013. 7. 28. import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class TestHexView03 { public static void printUsage() { System.out.println("java TestHexView03 [filename]"); } public static String toHex(byte b) { String s = ..

C# 언어로 작성하여 실행해 본 OpenGL 예제: Redbook 의 Teapots

컴파일에 필요한 dll 파일들은 CsGL 을 다운로드하면 들어 있다. 이전에 올린 C 언어용 소스와 Python 언어용 소스와 비교하면 이해할 수 있을 것이다. #region BSD License /* BSD License Copyright (c) 2002, Randy Ridge, The CsGL Development Team http://csgl.sourceforge.net/ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of..

프로그래밍/C# 2013.05.17

Python 언어로 작성하여 실행해 본 OpenGL 예제: Redbook 의 Teapots

아래의 파이썬용 소스를 실행시키자면 PyOpenGL 을 먼저 설치해야 한다. 소스의 구조는 C 언어 용으로 작성된 teapots,c 의 것과 거의 유사하다. # Filename: teapots.py # # See Wiki: http://www.de-brauwer.be/wiki/wikka.php?wakka=PyOpenGL # See Source: http://www.de-brauwer.be/wiki/wikka.php?wakka=PyOpenGLHelloWorld # See C Source: http://www.glprogramming.com/red/chapter03.html from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * ..

Visual C 2010 으로 컴파일하여 실행해 본 OpenGL 예제: Redbook 의 Teapots

Visual C 용으로 OpenGL 용 소스를 작성할 떼는 헤더 파일 gl.h 와 glu.h 는 사용하지 않아도 된다. glut.h 하나만 사용하면 된다. 컴파일할 때는 헤더 파일을 위한 경로나 라이브러리 파일을 위한 경로를 별도로 지정하지 않아도 된다. 즉, 명령 cl 소스파일명 으로 소스파일이 컴파일되어 실행파일이 생성된다. 아래 예제는 OpenGL Redebook 에 소개되어 있는 cube 예제 소스이다. /* * Copyright (c) 1993-1997, Silicon Graphics, Inc. * ALL RIGHTS RESERVED * Permission to use, copy, modify, and distribute this software for * any purpose and witho..

프로그래밍/C 2013.05.17

C# 언어로 작성하여 실행해 본 OpenGL 예제: Redbook 의 Cube

컴파일에 필요한 dll 파일들은 CsGL 을 다운로드하면 들어 있다. 이전에 올린 C 언어용 소스와 Python 언어용 소스와 비교하면 이해할 수 있을 것이다. #region BSD License /* BSD License Copyright (c) 2002, Randy Ridge, The CsGL Development Team http://csgl.sourceforge.net/ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of..

프로그래밍/C# 2013.05.10

Python 언어로 작성하여 실행해 본 OpenGL 예제: Redbook 의 Cube

아래의 파이썬용 소스를 실행시키자면 PyOpenGL 을 먼저 설치해야 한다. 소스의 구조는 C 언어 용으로 작성된 cube,c 의 것과 거의 유사하다. # Filename: cube.py # # See Wiki: http://www.de-brauwer.be/wiki/wikka.php?wakka=PyOpenGL # See Source: http://www.de-brauwer.be/wiki/wikka.php?wakka=PyOpenGLHelloWorld # See C Source: http://www.glprogramming.com/red/chapter03.html from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * def in..

Visual C 2010 으로 컴파일하여 실행해 본 OpenGL 예제: Redbook 의 Cube

Visual C 용으로 OpenGL 용 소스를 작성할 떼는 헤더 파일 gl.h 와 glu.h 는 사용하지 않아도 된다. glut.h 하나만 사용하면 된다. 컴파일할 때는 헤더 파일을 위한 경로나 라이브러리 파일을 위한 경로를 별도로 지정하지 않아도 된다. 즉, 명령 cl 소스파일명 으로 소스파일이 컴파일되어 실행파일이 생성된다. 아래 예제는 OpenGL Redebook 에 소개되어 있는 cube 예제 소스이다. // Filename: cube.c // // See: http://www.glprogramming.com/red/chapter03.html // #include // Commented out for Visual C // #include // Commented out for Visual C #in..

프로그래밍/C 2013.05.10

Java 언어로 간단한 피보나치 수 테이블 만들기

아래 처럼 피보나치(Fibonacci) 수 테이블을 출력하는 Java 소스이다. ------------------------------------------------- n F(n) ------------------------------------------------- 0 0 10 55 20 6,765 30 832,040 40 102,334,155 50 12,586,269,025 60 1,548,008,755,920 70 190,392,490,709,135 80 23,416,728,348,467,685 90 2,880,067,194,370,816,120 100 354,224,848,179,261,915,075 110 43,566,776,258,854,844,738,105 120 5,358,359,254..

Julia 언어로 평방근, 입방근, n제곱근 구하는 함수를 구현하고 테스트하기

음이 아닌 실수 A 의 평방근 sqrt(A) 를 구하는 Heron 의 방법: 반복함수 g(x) = (x + A/x) / 2 를 이용 실수 A 의 n제곱근 root(n, A) 를 구하는 Newton-Raphson 의 방법 반복함수 g(x) = ((n-1)*x + A/(x**(n - 1))) / n 를 이용 n = 2 인 경우에는 Newton-Raphson 의 방법이 Heron 의 방법과 동일하다. (참조. http://en.wikipedia.org/wiki/Newton's_method ) Julia 언어에는 지수 연산자 ^ 를 (밑수)^(지수) 의 형식으로 언어 자체에서 지원하고 있다. 하지만 차후 필요한 데가 있을 것 같아서 이와 유사한 n 제곱 함수와 n 제곱근 함수를 구현해 보았다. (참고로 Juli..