Contents

Develop
2003.04.23 09:45

[c] 소수점 반올림^^

Views 9684 Comment 0
?

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

# 소수점 반올림 간단 예제

#include<stdio.h>
#include<conio.h>
#include<stdio.h>

int gcd(int m, int n) {
    if (m<=0) return 0;
    if (n<=0) return 0;

    while(m != n}){
        if (m>n) m = m - n;
        else n = n - m;
    }

    return n;
}

void main(){
    float num,tmp;

    printf("Enter a float Number : ");
    scanf("%f",&num);

    tmp=(num*10);
    tmp=(tmp-(int)tmp)/10;

    if(tmp>=0.05) num=num+(0.10-tmp);

    printf("%fn",num);
}

void main(){
    int a,b;

    printf("Enter a first Number : ");
    scanf("%d",&a);

    printf("Enter a second Number : ");
    scanf("%d",&b);

    printf("GCD is %d",gcd(a,b));
    getch();
} 


?

List of Articles
No. Category Subject Author Date Views
349 System/OS [linux] 리눅스 활용 팁^^ hooni 2003.04.23 15541
348 System/OS [linux] 리눅스, 유닉스 CPU 이용률 확인.. hooni 2013.04.23 25883
347 System/OS [linux] 리눅스,유닉스 /proc/stat 파일 보는 법 hooni 2013.04.23 20707
346 System/OS [linux] 메일서버 세팅정보(sendmail) hooni 2003.04.23 18648
345 System/OS [linux] 메타(기호)문자의 의미와 사용 hooni 2003.04.23 17267
344 System/OS [linux] 새 하드디스크 추가하기..(내공쌓기) hooni 2003.04.23 14693
343 System/OS [linux] 센드메일 동적릴레이 설치 hooni 2003.04.23 16462
342 System/OS [linux] 셀 스크립트 if, for, case in.. hooni 2003.04.23 14492
341 System/OS [linux] 쉘 스크립트 (Shell Script) hooni 2003.04.23 13200
340 Develop [linux] 쉘 스크립트를 이용한 BBS hooni 2003.04.23 11399
339 System/OS [linux] 쉘 스크립트에 대한 설명과 예제.. hooni 2003.04.23 14479
338 System/OS [linux] 쉘 환경변수 PS1(프롬프트) hooni 2003.04.23 14607
Board Pagination Prev 1 ... 65 66 67 68 69 70 71 72 73 74 ... 99 Next
/ 99