Contents

조회 수 11460 댓글 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. [c] 도스 공격(DoS Attack) 프로그램

  2. [linux] GD 라이브러리 설치 방법..

  3. [linux] 초간단 Postfix, Covecot, SSL/TLS (SMTP)

  4. [c++] 기초강좌 #01(입출력,영역지정)

  5. Configure Postfix to Use Gmail SMTP on Ubuntu 18.04

  6. [c] 최단거리 알고리즘 & 예제소스..

  7. [js] 한글주소(URL) 인코딩(encode, Encoding), 자바스크립트(JavaScript)

  8. [switch] 시스코 스위치(catalyst 2950) telnet 설정

  9. [c] 최대공약수, 최소공배수, 서로소 구하기 (펌)

  10. [linux] 시스템 데몬 종류와 설명

  11. [자료구조] 트리(tree) 용어정리

  12. [linux] vi 편집기 간단한 명령과 환경설정

Board Pagination Prev 1 ... 33 34 35 36 37 38 39 40 41 42 ... 99 Next
/ 99