Develop
2013.04.23 14:41
[c] 거리와 각도를 입력받아서 좌표로 변환
조회 수 10817 댓글 0
첨부 '1' |
---|
극 좌표계의 좌표인 거리와 각도를 입력 받아서
직각 좌표계의 좌표 x, y 로 변환하는 프로그램
/* * 극 좌표계의 좌표인 거리와 각도를 입력 받아서 * 직각 좌표계의 좌표 x, y 로 변환하는 프로그램 */ #include <stdlib.h> #include <stdio.h> #include <math.h> #define PI 3.14159 #define X 0 #define Y 1 float* get_coord_ad( float degree, float distance ){ float* point = malloc( sizeof( float ) * 2 ); degree = PI * degree / 180; point[X] = distance * cos( degree ); point[Y] = distance * sin( degree ); return point; } int main(){ float dist, ang, *ptr_coord; printf( "Enter a distance : " ); scanf( "%f", &dist ); fflush( stdin ); printf( "Enter a degree : " ); scanf( "%f", &ang ); fflush( stdin ); ptr_coord = get_coord_ad( ang, dist ); printf( "\n극 좌표(%-4.2f, %-4.2f)를 직각 좌표로 변환하면 (%-4.2f, %-4.2f)입니다.\n", dist, ang, ptr_coord[X], ptr_coord[Y] ); free( ptr_coord ); return 1; }
-
[c] 네트워크 트래릭 모니터링.. 졸업작품..
-
[mysql] 루트 암호 초기화
-
[c] 소수 구하기 #2 (입력한 숫자가 소수인지 판별하기..)
-
[router] 라우팅 프로토콜 BGP (간단한 세팅)
-
[ios] 한샘 카달로그 앱 소스 (아이폰용)
-
[js] IE에서 인쇄 설정 팁
-
[c] scanf(), printf() 포맷의 형변환
-
[python] 파이썬 공부하는 사이트~
-
[js] 순환참조에 의한 메모리 누수 관련
-
[c] 거리와 각도를 입력받아서 좌표로 변환
-
[unix] 로그파일 정리 쉘스크립트
-
OSI (Open Systems Interconnection) 개방형 시스템간 상호 접속