문제
10진수를 16진수로 바꾸거나 16진수를 10진수로 변환하는 프로그램을 제작해보라.
작성 코드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void main() | |
{ | |
char key; | |
int data; | |
printf("10진수 --> 16진수로 변환하는 프로그램이다. \n"); | |
printf("10진수를 16진수로 바꾸려변 [A] 키를 누르고, \n"); | |
printf("16진수를 19진수로 바꾸려변 [B] 키를 누르세요. \n"); | |
printf("a나 b를 누르세요 : "); | |
scanf("%c", &key); | |
printf("변환할 숫자를 입력하세요 : "); | |
if (key == 'a') { | |
scanf("%d", &data); | |
printf("10진수 값 : %d --> 16진수 값 : %x", data, data); | |
} | |
else if(key == 'b') { | |
scanf("%d", &data); | |
printf("10진수 값 : %d --> 16진수 값 : %x", data, data); | |
} | |
else { | |
printf("A나 B를 입력해 주세요"); | |
} | |
} |
'Computer Science > Problem Solving' 카테고리의 다른 글
[알고리즘 문제풀이 전략]04 피보나치 수열 byC언어 (0) | 2017.08.19 |
---|---|
[알고리즘 문제풀이 전락]02 숫자 맞추기 byC언어 (0) | 2017.08.19 |
[tryhelloworld]JadenCase문자열 만들기 by파이썬 (1) | 2017.08.16 |
[tryhelloworld]하샤드 수 by파이썬 (0) | 2017.08.16 |
[tryhelloworld]딕셔너리 정렬 by파이썬 (0) | 2017.08.16 |