Contents

Views 10814 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;
}



?

  1. [c] 구조체의 설명과 예제..

    Date2003.04.23 CategoryDevelop Byhooni Views8373
    Read More
  2. [c] 구조체/파일 입출력 프로그램

    Date2003.04.23 CategoryDevelop Byhooni Views7063
    Read More
  3. [c] 구조체 배열 예제 (학생 성적 계산)

    Date2013.04.23 CategoryDevelop Byhooni Views7666
    Read More
  4. [c] 구구단 최단라인 ㅡㅡ;

    Date2013.04.23 CategoryDevelop Byhooni Views8003
    Read More
  5. [c] 관계형 연산자에 대한 설명

    Date2013.04.23 CategoryDevelop Byhooni Views7667
    Read More
  6. [c] 공용체를 이용해 MSB를 LSB로 변환

    Date2013.04.23 CategoryDevelop Byhooni Views9374
    Read More
  7. [c] 격자 직사각형 넓이 구하기

    Date2013.04.23 CategoryDevelop Byhooni Views7457
    Read More
  8. [c] 게임 AI FSM 테스트 샘플 소스.. 꽤 괜찮은 소스..

    Date2013.04.23 CategoryDevelop Byhooni Views7370
    Read More
  9. [c] 거리와 각도를 입력받아서 좌표로 변환

    Date2013.04.23 CategoryDevelop Byhooni Views10814
    Read More
  10. [c] 간단한 채팅(클라이언트/서버) 프로그램 소스

    Date2003.04.23 CategoryDevelop Byhooni Views9068
    Read More
  11. [c] 간단한 점 이동 샘플 소스코드

    Date2013.04.23 CategoryDevelop Byhooni Views6541
    Read More
  12. [c] 간단한 자료구조(stack, queue, linked list) 구현 소스

    Date2003.04.23 CategoryDevelop Byhooni Views10106
    Read More
Board Pagination Prev 1 ... 47 48 49 50 51 52 53 54 55 56 ... 71 Next
/ 71