Contents

조회 수 11457 댓글 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

    Date2013.07.22 CategoryDevelop Byhooni Views14537
    Read More
  2. [c] flooding 알고리즘 미로 찾기(도스용) 소스코드

    Date2003.04.23 CategoryDevelop Byhooni Views14528
    Read More
  3. [linux] 셀 스크립트 if, for, case in..

    Date2003.04.23 CategorySystem/OS Byhooni Views14501
    Read More
  4. [linux] 쉘 스크립트에 대한 설명과 예제..

    Date2003.04.23 CategorySystem/OS Byhooni Views14484
    Read More
  5. [js] 자바스크립트를 동적으로 로딩하기

    Date2013.04.23 CategoryDevelop Byhooni Views14457
    Read More
  6. [html] 캐쉬된 웹페이지 사용하지 않도록 하는 방법

    Date2003.04.23 CategoryDevelop Byhooni Views14451
    Read More
  7. [linux] ipchains 옵션

    Date2003.04.23 CategorySystem/OS Byhooni Views14450
    Read More
  8. [linux] 기존 환경설정 저장하면서 커널 컴파일..

    Date2003.04.23 CategorySystem/OS Byhooni Views14448
    Read More
  9. [linux] Xwindow/Xmanager 사용

    Date2003.04.23 CategorySystem/OS Byhooni Views14395
    Read More
  10. [linux] 간단한 vi편집기 사용 명령

    Date2003.04.23 CategorySystem/OS Byhooni Views14383
    Read More
  11. [ios][swift] 초간단 카달로그 앱 (Catalog App)

    Date2016.06.27 CategoryDevelop Byhooni Views14314
    Read More
  12. [c#] 파일(File) 쓰기 ㅎㅎ

    Date2013.04.23 CategoryDevelop Byhooni Views14296
    Read More
Board Pagination Prev 1 ... 24 25 26 27 28 29 30 31 32 33 ... 99 Next
/ 99