Develop
2013.04.23 12:47
[c] 최대공약수, 최소공배수, 서로소 구하기 (펌)
조회 수 12271 댓글 0
소스코드
#include<stdio.h> main() { int max, min,c,i,j,cdmin,csmax; for(;;) { printf("임의의값 2개중 1개를 입력하시오"); scanf("%d", &max); printf("임의의값 2개중 나머지 1개를 입력하시오"); scanf("%d", &min); if (max<min) { c=max; max=min; min=c; printf("MAX=%dMIN=%d\n",max, min ); } else if (max>min) printf("max=%dmin=%d\n",max, min ); else { printf("같다.\n"); break; } printf("최대공약수는 1을 최소공배수는 2를입력하시오"); scanf("%d",&c); if (c==1) { for(i=1 ; i<=min ; i++) { if (min%i==0 && max%i==0) cdmin=i; } if (cdmin==1) printf("서로소인수\n"); else printf("최대공약수=%d\n",cdmin); } else { csmax=0; for(i=1 ; i<=999 ; i++) { for(j=1; j<=999 ; j++) { if (min*i==max*j) { csmax=min*i; break; } } if (csmax!=0) break; } printf("최소공배수=%d\n",csmax); } printf("계속할라믄 1번을 종료할라믄 2번을..."); scanf("%d", &c); if(c!=1) break; } }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
925 | System/OS | [linux] split 명령어 | hooni | 2014.03.11 | 5207 |
924 | Develop |
[ios] iOS 의 인앱구매 소개
![]() |
hooni | 2014.04.29 | 5258 |
923 | Develop | [ios] URL Scheme 이용하여 앱 설치 확인 | hooni | 2014.03.10 | 5287 |
922 | Develop |
[ios][swift] 초간단 TableView 샘플
![]() |
hooni | 2016.06.27 | 5291 |
921 | System/OS | [linux] CentOS Apache Httpd에 https 적용 | hooni | 2014.03.05 | 5335 |
920 | Develop |
[ios] 앱딜리게이트 라이프사이클 (AppDelegate Lifecycle)
![]() |
hooni | 2014.05.09 | 5341 |
919 | Develop | What is difference between Get, Post, Put and Delete? | hooni | 2018.02.28 | 5345 |
918 | Develop |
[ios] iOS 7 이상 UIBarButtonItem 여백
![]() |
hooni | 2014.03.27 | 5387 |
917 | Database | [mysql] 중복데이터 삭제하는 초간단 쿼리 | hooni | 2017.11.22 | 5417 |
916 | Develop | [android] 초간단 얼럿 (AlertDialog) | hooni | 2016.10.21 | 5455 |
915 | System/OS | [linux] resolv.con 초기화 되는 문제 | hooni | 2014.04.05 | 5463 |
914 | Develop |
[ios] AES256 알고리즘을 이용해 데이터 암호화/복호화 방법
![]() |
hooni | 2015.07.21 | 5465 |