Last active
December 10, 2015 15:19
-
-
Save Jack2/4453859 to your computer and use it in GitHub Desktop.
- A Nice Compliment(http://www.cstutoringcenter.com/cryptography/problems.php?id=4) - Being a tourist (http://www.cstutoringcenter.com/cryptography/problems.php?id=5)
This file contains hidden or 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 <iostream> | |
#include <stdio.h> | |
#include <string.h> | |
#include <string> | |
#include <sstream> | |
using namespace std; | |
int main() | |
{ | |
string str= ""; | |
char input1,input2, ans[1], ans_str[20]; | |
int output; | |
stringstream stream1, stream2; | |
int count=0; | |
cout << "Input Hex Value => Output Ascii Value (Result => input 0)" << endl; | |
do { | |
//stringstream 사용 시 초기화를 해야 재사용 가능 | |
stream1.clear(); | |
cout << "Input Hex Value : " ; | |
cin >> str; | |
//cout << "Your Input Value is " << str << endl; | |
stream1 << str; | |
//초기화를 안한 경우 1회만 정상작동하여 stream 값이 0으로 출력되는 것을 확인 | |
//cout << "Your Input Value is " << stream << endl; | |
stream1 >> hex >> output ; | |
//cout << "Your Decimal Value is " << output << endl; | |
sprintf(ans,"%c",output); | |
if (count == 0) { | |
strcpy(ans_str,""); | |
strcat(ans_str, ans); | |
} else strcat(ans_str, ans); | |
//printf ("Your Output is %c\n", output); | |
count++; | |
} while (output!=0); | |
// 0을 입력시 프로그램이 종료가 되면서 한 번에 답을 출력해 준다. | |
cout << "Bye" << endl; | |
cout << "Answer is " << ans_str << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment