Level : WORDPRESS BOOK LINKEDIN PATENT Send Mail 동냥하기 hajunho.com

097

살며 생각하며, / / 2020. 3. 3. 10:27
반응형

1. 다음과 같은 이진 트리가 있을 때

[멋드러진 이진 트리]

다음 순회 방식에 따른 노드 방문 순서를 적으세요.

(1) in-order :   ->     ->     ->   ...          (5점)
(2) pre-order :    ->     ->     -> ...          (5점)
(3) post-order :     ->     ->     ->  ...       (5점)
(4) level-order :     ->     ->     ->  ...      (5점)

2. 원하는 언어(의사코드 가능)로 다음 데이터 구조를 손코딩으로 구현 하세요.

(1) 이진 트리 1차원 배열 표현(15점)


(2) 이진 트리 연결 리스트 표현(15점)

* 보너스 문제(10점)

(3) 이진 트리 연결 리스트 표현에서 [삽입]을 추가 구현하세요.


향 후 제가 진행할 프로젝트도 이야기 할거고 경영진에게도 논리적으로 제가 했던 것 제가 알아서 설명하겠습니다.
그리고 혹시 다른 생각 하실 까봐 덧붙인다면,
지금 *강사님 *강사님 팀장님 손 놓으셔도 지금 진행하는 프로젝트 한달 남은 기간동안 다 성공시킬 자신 있습니다.
자신 없어서 문제니 뭐니 하는거 아니니 이해하셨길 바랍니다.
그리고 가족과 떨어져서 있는거 쉬운 일 아닙니다. 한달간 계속 내려오긴 합니다만.
제가 계속 괜찮다고 하는 부분 앞으로는 괜찮다고 안하겠습니다.

3 번째 이유에서
- 이건 어느 정도 포기를 했습니다. 
- *강사와 * 강사님이 커뮤니케이션 안된다는 이야기는 **에 하면 안되는데 영진군이 **에 이야기를 했습니다.  원래 강사님이나 운영자가 더 좋다고 하면서 내려오실 때 챙기거나 애살있게 붙어서 프로젝트 질문을 하기보다는 스스로 하는 편이 좋고,  평가를 안 받고 최대한 자유롭게 지내는 것이 좋다는 분위기가 확산되고 있습니다. 전체로 퍼지지는 않겠지만, 해당 분위기를 격리 시키고  아이들이 집중할 수 있는 분위기를 만드는데 최선을 다했습니다. 저는 퇴근해도 새벽께나 항상 들르고 있고, 지연 출근신청도 잘 안하지만 한다고 해도  일찍 출근을 합니다. 출/퇴근 시간이 중요하지는 않겠지만 멤버들이 공부할 물리적 시간 확보 분위기는 잘 만들고 있다고 생각 됩니다.  그리고 굳이 이야기 안해도 될 멤버들간의 사적인 부분도 다 보고를 하고 있었다고 생각이 됩니다.




#pragma NOTICE(Config 와 Logger 항목은 하드코딩.)

char buffer[32];
LPCWSTR pwstrDest;
wsprintf(buffer, "%d", dwInternetStatus);
  int nLen = ( int )strlen( buffer ) + 1;
        mbstowcs( pwstrDest, buffer, nLen );
AfxMessageBox( _D_(pwstrDest) ); //THIS MESSAGES BOX DOES NOT SHOW UP 

  mbstowcs( pwstrDest, buffer, nLen );
wsprintf(buffer, "%d", lpvStatusInformation);
AfxMessageBox( _D_(pwstrDest) ); //THIS MESSAGES BOX DOES NOT SHOW UP 




#include "StdAfx.h"
#include "CosmeticService.h"
#include "MainFrm.h"
#include "FtpSession.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


CosmeticService::CosmeticService(void)
{
}

CosmeticService::~CosmeticService(void)
{
}


void CosmeticService::ConnectionAndGetHashTest(void)
{
// AfxMessageBox(_T("ConnectionAndGetHashTest"));
CString StrServer = NULL;
CString strHtml = NULL;
StrServer = "http://.57.201.145:1337/hash";
CInternetSession *pSession = new CInternetSession;
pSession->SetOption(INTERNET_OPTION_RECEIVE_TIMEOUT, 5000);
pSession->SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 5000);
CHttpFile* pFile = (CHttpFile*) pSession->OpenURL((LPCTSTR) StrServer, 1,
INTERNET_FLAG_RELOAD | INTERNET_FLAG_TRANSFER_BINARY);
DWORD dwStatusCode;
pFile->QueryInfoStatusCode(dwStatusCode);
if (dwStatusCode == HTTP_STATUS_OK) {
CString strLength = NULL;
CString strHeaders = NULL;
pFile->QueryInfo(HTTP_QUERY_CONTENT_LENGTH, strLength);
pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strHeaders);
long lLength = 4096 * 100;
byte* pbHtml = new byte[lLength];
memset(pbHtml, 0, lLength);
byte sRecived[512];
int iIndex = 0;
int num = 0;
while ((num = pFile->Read(sRecived, 512)) > 0) {
memcpy(pbHtml + iIndex, sRecived, num);
iIndex += num;
}
pbHtml[iIndex] = NULL;
//strHtml = (CHAR *) pbHtml;
g_sCosmeticHASH = (CHAR *) pbHtml;
AfxMessageBox(g_sCosmeticHASH);
}
}

void CosmeticService::RequestRESTfulTEST(void) {
CString strSendMsg;
CString strOutMsg;
CString StrServer = NULL;
StrServer = "http:// .57.201.145:1337/request";
strSendMsg = _T("emergency:1");

RequestPost(StrServer, strSendMsg, strOutMsg);
}

//RESTful : POST
BOOL CosmeticService::RequestPost(LPCTSTR lpUrl, CString strSendMsg,
CString strOutMsg) {
BOOL bRet = FALSE;
CString strHtml = NULL;

DWORD dwSearviceType;
CString strServer, strObject;
INTERNET_PORT nPort;

if (!AfxParseURL(lpUrl, dwSearviceType, strServer, strObject, nPort)) {
strHtml = "RequestPost Fail";
AfxMessageBox(strHtml);
ASSERT(0);
return bRet;
}

CString strReciveMessage("");
DWORD dwReadSize = 0;

FtpSession session;
CHttpConnection* pServer = NULL;
CHttpFile *pFile = NULL;

CString strHeader = NULL;
//동작 X : strHeader = "Content-Type:application/x-www-form-urlencoded";
strHeader = _T("Content-Type:application/x-www-form-urlencoded\r\n");

try {

pServer = session.GetHttpConnection(strServer, nPort);
if (!pServer) {
pServer->Close();
exit(-1);
}

pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, strObject,
NULL, 1, NULL, NULL,
INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_EXISTING_CONNECT
| INTERNET_FLAG_RELOAD);

if (!pFile) {
exit(-1);
}

char szURLEncoded[256] = { 0, };

CString strAPost = L"";
//동작 X : CStringW ...
//동작 X : strAPost.Format(L"emergency=1&hash=하준123123F&text=%s",L"%20%48%65%6C%6C%6F%20%57%6F%72%6C%64");
//strAPost = strOutMsg;
//동작 X : CStringW cstringw(strAPost);
//동작 X : AfxMessageBox(cstringw);
//동작 X : BOOL result = pFile->SendRequest(strHeader, (LPVOID)(LPCTSTR)strSendMsg, strSendMsg.GetLength());
//결론 : 클라이언트 서버 모두 utf-8로 설정해도 CString 으로는 unicode가 지원되지 않음.

//CStringA strAPost = "";

pFile->AddRequestHeaders(_T("POST v1/voice/tts.bin HTTP/1.1\r\n"));
pFile->AddRequestHeaders(_T("Host: openapi.naverlove.com\r\n"));
pFile->AddRequestHeaders(_T("User-Agent: curl/7.43.0\r\n"));
pFile->AddRequestHeaders(_T("Accept: */*\r\n"));
pFile->AddRequestHeaders(
_T("Content-Type: application/x-www-form-urlencoded;charset=UTF-8\r\n"));
//pFile->AddRequestHeaders( _T("charset=utf-8\r\n"));
pFile->AddRequestHeaders(
_T("X-Naver-Client-Id: 123456789123456789\r\n"));
pFile->AddRequestHeaders(_T("X-Naver-Client-Secret: 12345678\r\n"));

//strAPost.Format("emergency=1&hash=하준123123F&text=%s","%20%48%65%6C%6C%6F%20%57%6F%72%6C%64");
strAPost.Format(L"emergency=1&hash=하준123123F&text=1&%s",L"%20%48%65%6C%6C%6F%20%57%6F%72%6C%64");

LPCTSTR  strPot2 = strAPost;
const int dwLength = _tcslen(strPot2);
char *strPot = new char[dwLength];
WideCharToMultiByte(CP_ACP, 0, strPot2, -1, strPot, dwLength, 0, 0);

//동작 O : strAPost.Format("emergency=1&hash=FEFEFEF&text=%s","%20%48%65%6C%6C%6F%20%57%6F%72%6C%64");
//BOOL result = pFile->SendRequest(strHeader,
// (LPVOID) strAPost.GetBuffer(0), strAPost.GetLength());

AfxMessageBox(_T("유니코드테스트"));
//AfxMessageBox(CString(strPot));
BOOL result = pFile->SendRequest(strHeader,  strPot, dwLength);

// BOOL result = pFile->SendRequest(strHeader,
// (LPDWORD) strAPost.GetBuffer(0), strAPost.GetLength() + 1);

strAPost.ReleaseBuffer();

CString vResult = NULL;

vResult = result ? "true" : "false";
AfxMessageBox(vResult);

strSendMsg.ReleaseBuffer();

} catch (CInternetException* e) {
TCHAR szError[255];
e->GetErrorMessage(szError, 255);
e->Delete();
return bRet;
}

dwReadSize = pFile->Read(strReciveMessage.GetBuffer(pFile->GetLength()),
pFile->GetLength());
strReciveMessage.ReleaseBuffer();

if (dwReadSize != (DWORD) strReciveMessage.GetLength())
bRet = FALSE;
else
bRet = TRUE;

strOutMsg = strReciveMessage;

if (pFile) {
pFile->Close();
delete pFile;
pFile = NULL;
}

if (pServer) {
pServer->Close();
delete pServer;
pServer = NULL;
}

session.Close();
return bRet;
}

//30MB 정상 동작 확인 완료
//TODO : but 라이브러리 구매 혹은 FTP 구현 필요
void CosmeticService::FTPbaseCodeTest(CString file2upload) {
BOOL bRet = FALSE;
FtpSession session;
CFtpConnection *pConnection = NULL;

session.EnableStatusCallback(TRUE);

//g_kpMainFrame->ProgressBegin(100, _T("progress_bar later if it's needed."));
//g_kpMainFrame->ProgressStep();

try {
pConnection = session.GetFtpConnection(_T(" .57.201.145"),
_T("morpheus"), _T("worldBest@1"), (INTERNET_PORT) 3317, TRUE);

if (pConnection) {
AfxMessageBox(_T("전송을 시작합니다."));
} else {
AfxMessageBox(_T("Error"));
pConnection = NULL;
return;
}

g_sCosmeticHASH = L"/"+ g_sCosmeticHASH;
g_sCosmeticHASH.Remove('"');
AfxMessageBox(g_sCosmeticHASH);
if(!pConnection->CreateDirectoryW(g_sCosmeticHASH)) {
AfxMessageBox(_T("CreateDirectory Error"));
pConnection->Close();
session.Close();
}

// g_kpMainFrame->ProgressSetPos(50);

// FTP 서버의 폴더 경로 얻기
CString strCurrentDirectory;

if (!pConnection->SetCurrentDirectory(L"/"+g_sCosmeticHASH)) {
AfxMessageBox(_T("SetCurrentDirectory Error"));
pConnection->Close();
session.Close();
} else {
AfxMessageBox(_T("SetCurrentDirectory g_sCosmeticHASH"));
}


REQUEST_CONTEXT rc;// Send Context to Callback function
// rc.hWindow = g_kpMainFrame->m_Progress; // ProgressBar control windo

CString strSendMsg;
CString strOutMsg;
CString StrServer = NULL;
StrServer = "http:// .57.201.145:1337/request";
g_sCosmeticHASH.Remove('/');
strSendMsg = _T("emergency:1&hash=") + g_sCosmeticHASH;

AfxMessageBox(_T("RequestPost"));

RequestPost(StrServer, strSendMsg, strOutMsg);

if (pConnection->PutFile(file2upload, file2upload.Right(file2upload.GetLength() - file2upload.ReverseFind('\\')-1), FTP_TRANSFER_TYPE_BINARY, (DWORD)&rc)) {
AfxMessageBox(_T("Done."));

} else {
AfxMessageBox(_T("PutFile Error"));
}

// g_kpMainFrame->ProgressEnd();

} catch (CInternetException *pEx) {
pEx->ReportError(MB_ICONEXCLAMATION);
pConnection = NULL;
pEx->Delete();
}
pConnection->Close();
}

///////////////////////////////////////////////////////////////////////
//char 에서 wchar_t 로의 형변환 함수
wchar_t* CosmeticService::ConverCtoWC(char* str)
{
    //wchar_t형 변수 선언
    wchar_t* pStr;
    //멀티 바이트 크기 계산 길이 반환
    int strSize = MultiByteToWideChar(CP_ACP, 0,str, -1, NULL, NULL);
    //wchar_t 메모리 할당
    pStr = new WCHAR[strSize];
    //형 변환
    MultiByteToWideChar(CP_ACP, 0,str, strlen(str)+1, pStr, strSize);
    return pStr;
}

///////////////////////////////////////////////////////////////////////
//wchar_t 에서 char 로의 형변환 함수
char * CosmeticService::ConvertWCtoC(wchar_t* str)
{
    //반환할 char* 변수 선언
    char* pStr ; 

    //입력받은 wchar_t 변수의 길이를 구함
    int strSize = WideCharToMultiByte(CP_ACP, 0,str,-1, NULL, 0,NULL, NULL);
    //char* 메모리 할당
    pStr = new char[strSize];

    //형 변환 
    WideCharToMultiByte(CP_ACP, 0, str, -1, pStr, strSize, 0,0);
    return pStr;
}
i

반응형

'살며 생각하며,' 카테고리의 다른 글

099  (0) 2020.03.04
098  (0) 2020.03.03
096  (0) 2020.03.03
095  (0) 2020.02.26
094  (0) 2020.02.26
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기