프로그래밍/C++ 58

스트링 배열에서 스트링 찾기(find) for .NET with Visual C++/CLI

[파일명: TestStringFindApp.cpp]------------------------------------------------ // Filename: TestStringFindApp.cpp // // Compile: cl /clr TestStringFindApp.cpp // Execute: TestStringFindApp using namespace System; using namespace System::Collections; using namespace System::Collections::Generic; void PrintArray(array^ arr); bool Contains(String^ s) { return s->IndexOf("셋") >= 0; } int main(array ^a..

프로그래밍/C++ 2009.04.30

명령행 인자 처리 예제 for .NET with C++/CLI

소스 파일명: testArgumentsCli.cpp // Filename: testArgumentsCli.cpp // // Compile: cl /clr testArgumentsCli.cpp // Execute: testArgumentsCli using namespace System; int main(array ^args) { int i; double sum = 0.0; // 초기화 // 명령행 인자(command-line argument) 개수 출력 Console::WriteLine("Count of arguments: {0}", args->Length); for (i = 0; i Length; i++) { // 스트링을 배정밀도 부동소수점수로 변환하여 누적 sum += Convert::..

프로그래밍/C++ 2009.04.29

Hello 예제 for .NET with C++/CLI

C++/CLI는 Visual C++ 2008 부터 등장한 .NET 용 새로운 C++ 프로그램 언어이다. 이는 Visual C++ 2005에 쓰이던 MC++(Mananged C++)의 약점을 보완하며 대체한다. [참고 자료] 1. http://www.codeproject.com/KB/mcpp/cppcliintro01.aspx 2. http://blog.voidnish.com/index.php?p=11 3. http://recoverlee.tistory.com/37?srchid=BR1http%3A%2F%2Frecoverlee.tistory.com%2F37 ------------------------------[소스 시작] // Filename: helloWorldCli.cpp // // Compile: cl..

프로그래밍/C++ 2009.04.29

스트링 리스트에서 스트링 찾기(find) with C++ STL

[파일명: testStringFindInList.cpp]------------------------------------------------ #include #include #include #include #include using namespace std; struct SData { SData(string s) : m_s(s) {} string m_s; }; namespace std { template struct greater { bool operator()(SData const* p1, SData const* p2) { //Defined like less for ascending sorting if(!p1) return true; if(!p2) return false; return p1->m_s ..

프로그래밍/C++ 2009.04.22

스트링 벡터에서 스트링 찾기(find) with C++ STL

[파일명: testStringFindInVector.cpp]------------------------------------------------ #include #include #include #include using namespace std; void printArray(vector arr); int main() { int SIZE = 6; string data[] = { "하나", "둘", "셋", "넷", "다섯", "여섯" }; vector words(&data[0], &data[SIZE]); vector::iterator it; ///////////////////////////////// // words[0] = "하나"; // words[1] = "둘"; // words[2] = "셋"; ..

프로그래밍/C++ 2009.04.22

스트링 배열 정렬(sorting)하기 for .NET with Visual C++

[파일명: testSortApp.cpp]------------------------------------------------ using namespace System; using namespace System::Collections; using namespace System::Collections::Generic; void printArray(array^ arr); int main(int argc, char *argv[]) { array^ arr = gcnew array(argc - 1); for (int i = 1; i < argc; i++) { arr[i-1] = gcnew String(argv[i]); } Array::Sort(arr); printArray(arr); } void printArra..

프로그래밍/C++ 2009.04.20

손으로 계산하는 긴자리 곱셈표 만들기 with C++

초등학교 때 배우는 두 정수의 곱셈표를 만들어 주는 C++ 소스이다. /* * Filename: makeMultTableCPP.cpp * * Print a multiplication table. * * Compile: cl /EHsc makeMultTableCPP.cpp * Execute: makeMultTableCPP 230 5100 * * Date: 2009/03/07 * Author: pkim (AT) scripts.pe.kr */ #include #include #include using namespace std; void printUsing(); void printMultTable(int x, int y); int main(int argc, char *argv[]) { long x, y; if ..

프로그래밍/C++ 2009.03.07

STL을 이용한 RPN 계산기 소스 for C++

아래의 소스는 http://www.fredosaurus.com/notes-cpp/examples/rpn/rpn.html 에 올려져 있는 그대로의 (명령행 RPN 계산기) C++ 소스입니다. 소스가 매우 간단하다. 그러나 부족한 점이 몇 가지 눈에 띤다. 1) 소수점 있는 수를 처리하지 못한다. 2) 음수를 피연산자로 쓸 수 없다. 3) 기타 이런 점을 개선한 소스는 http://www.scripts.pe.kr/wiki/wiki.php/RPNCalc 에서 볼 수 있다. // stl/rpn.cpp -- RPN (Reverse Polish Notation) Calculator // Fred Swartz 2001-12-05, 2002-09-27 #include #include #include #include u..

프로그래밍/C++ 2009.02.07