전체 글 725

스트링 배열에서 스트링 찾기(find) with Groovy

우선 다음 소스는 Java용 소스를 //// 표시가 붙은 줄 한 줄만 수정하여 Groovy영 소스로 고친 것이다. [파일명: testStringFindApp.groovy]------------------------------------------------ import java.util.*; public class TestStringFindApp { public static void main(String[] args) { String[] words = [ "하나", "둘", "셋", "넷", "다섯", "여섯" ] as String[]; //// int where; System.out.print("array: "); printArray(words); where = find(words, "셋"); if (..

스트링 리스트에서 스트링 찾기(find) with Java

[파일명: TestStringFindInList.java]------------------------------------------------ import java.util.*; public class TestStringFindInList { public static void main(String[] args) { String[] data = { "하나", "둘", "셋", "넷", "다섯", "여섯" }; ArrayList words = new ArrayList(); for (int i = 0; i < data.length; i++) { words.add(data[i]); } int where; System.out.print("vector: "); printArray(words); where = fi..

스트링 벡터에서 스트링 찾기(find) with Java

[파일명: TestStringFindInVector.java]------------------------------------------------ import java.util.*; public class TestStringFindInVector { public static void main(String[] args) { String[] data = { "하나", "둘", "셋", "넷", "다섯", "여섯" }; Vector words = new Vector(); for (int i = 0; i < data.length; i++) { words.add(data[i]); } int where; System.out.print("vector: "); printArray(words); where = find..

스트링 배열에서 스트링 찾기(find) with Java

[파일명: TestStringFindApp.java]------------------------------------------------ import java.util.*; public class TestStringFindApp { public static void main(String[] args) { String[] words = { "하나", "둘", "셋", "넷", "다섯", "여섯" }; int where; System.out.print("array: "); printArray(words); where = find(words, "셋"); if (where > 0) { System.out.print("발견! "); System.out.println("Next word of 셋 in array:..

스트링 리스트에서 스트링 찾기(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