Contents

조회 수 10814 댓글 0
Atachment
첨부 '1'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
극 좌표계의 좌표인 거리와 각도를 입력 받아서
직각 좌표계의 좌표 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;
}



?

  1. [ios] App States

  2. [html] 캐쉬된 웹페이지 사용하지 않도록 하는 방법

  3. [js] AngularJS를 소개합니다.

  4. [php] 심플한 게시판 ㅋㅋ

  5. [js] 자바스크립트의 클로저 (JavaScript's Closure)

  6. [c] 다중연결 서버 만들기 #1 - fork() 사용

  7. [doc] UI개발시 유용한 소프트웨어 (개발 및 디버깅 툴)

  8. [html] HTML5 튜토리얼 링크 ㅋㅋ

  9. [c++] Win32 API 기본 출력인 MessageBox() 함수 사용 예제..

  10. [c] flooding 알고리즘 미로 찾기(도스용) 소스코드

  11. [ios] 네트워크 인디케이터(NetworkActivityIndicator) 작동

  12. [php] php5.3부터는 eregi()대신 preg_match()를 사용

Board Pagination Prev 1 ... 11 12 13 14 15 16 17 18 19 20 ... 71 Next
/ 71