Contents

Views 10849 Comment 0
Atachment
Attachment '1'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
극 좌표계의 좌표인 거리와 각도를 입력 받아서
직각 좌표계의 좌표 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;
}



?

List of Articles
No. Category Subject Author Date Views
277 Develop 프로그래밍에서 foo, bar 함수의 유래 file hooni 2013.06.25 21488
276 Develop [ios] PHP로 APNS 프로바이더~ file hooni 2013.06.27 16992
275 Develop [ios] APNS 클라이언트 구현 (pdf) file hooni 2013.06.27 15842
274 Develop [ios] APNS 샘플 코드.. secret hooni 2013.06.27 0
273 Develop [android] GCM 사용하기 1 (GCM 서비스 신청하기) file hooni 2013.07.06 51430
272 Develop GCM 사용하기 2 (단말에 GCM 구현하기) file hooni 2013.07.06 23418
271 Develop GCM 사용하기 3 (JSP로 GCM 푸시 서버 만들기) 4 file hooni 2013.07.06 25432
270 Develop git 브런치 배우기 (링크) hooni 2013.07.09 20706
269 Develop [ios] App States file hooni 2013.07.22 13256
268 Develop [ios] Background 에서 네트워크 사용 file hooni 2013.07.22 11600
267 Develop [ios] 소소한 팁 (Rect,Point,Path,URL 등) hooni 2013.08.08 29535
266 Develop [ios] libxml/tree.h file not found file hooni 2013.08.08 18773
Board Pagination Prev 1 ... 43 44 45 46 47 48 49 50 51 52 ... 71 Next
/ 71