Skip to content

Instantly share code, notes, and snippets.

@synchrok
Created March 9, 2013 19:57
Show Gist options
  • Save synchrok/5125522 to your computer and use it in GitHub Desktop.
Save synchrok/5125522 to your computer and use it in GitHub Desktop.
* eulrlera (을를이가) * 단어 뒤에 붙을 말이 을(이/은)인지 를(가/는)인지 알려주는 함수 * @param (wchar_t*) * @return true(을, 이, 은) / false(를, 가, 는)
#include <windows.h>
#include <iostream>
#include <locale>
using namespace std;
boolean eulrlega(wchar_t *word)
{
int len = wcslen(word);
wchar_t completeCode = word[len-1];
if(completeCode < 0xAC00 || completeCode > 0xD7AF)
return true;
wchar_t unicode = completeCode - 0xAC00;
wchar_t jong = unicode % 28 + 0x11A7;
if(jong != 4519)
return true;
else
return false;
}
wchar_t* getEulrl(wchar_t *word) {
return eulrlega(word)? L"을" : L"를";
}
wchar_t* getEga(wchar_t *word) {
return eulrlega(word)? L"이" : L"가";
}
wchar_t* getEunnn(wchar_t *word) {
return eulrlega(word)? L"은" : L"는";
}
int main()
{
wcin.imbue( locale("korean") );
wcout.imbue( locale("korean") );
wcout << L"고기" << getEulrl(L"고기") << L" 먹고싶다 \n";
wcout << L"라면" << getEulrl(L"라면") << L" 먹고싶다 \n\n";
wcout << L"고기" << getEga(L"고기") << L" 먹고싶다 \n";
wcout << L"라면" << getEga(L"라면") << L" 먹고싶다 \n\n";
wcout << L"고기" << getEunnn(L"고기") << L" 맛있다 \n";
wcout << L"라면" << getEunnn(L"라면") << L" 맛있다 \n\n";
system("pause");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment