¶
됐는 모르.
문를 리 .
면 배 는 .
데블 배듯, 를 는 럼
밍 는 매 느낀.
문를 리 .
면 배 는 .
데블 배듯, 를 는 럼
밍 는 매 느낀.
리 ¶
냥 리 . 떻 보면 복 .ㅡ
His teaching method is very good.
번 밍 리.
.(는 문 보는 .)
, H, t, m, i, v, g .
문 , 볼 동 부 .
만 Hot는 를 문 , 먼 H 는 문 His 를 .
o i.. 르 문 found 0 못 린.
만 부 동 면 못 린.
His teaching method is very good.
번 밍 리.
.(는 문 보는 .)
, H, t, m, i, v, g .
문 , 볼 동 부 .
만 Hot는 를 문 , 먼 H 는 문 His 를 .
o i.. 르 문 found 0 못 린.
만 부 동 면 못 린.
¶
~cpp #include <stdio.h> void exist_word(char x[40], int exist_str[10]); //x[i] 문 무 int compare_str(char x[40], char search_str[15], int exist_str[10]); // 문 int word_num = 1, search_str_num = 0; int found = 0; int temp = 0; void main() { char x[40] = "His teaching method is very good."; char search_str[15]; int exist_str[10]; // exist_str[i]는 x문 i번 문 몇번 문 FILE *fp; fp = fopen("result.out", "w"); while(1){ word_num = 1; search_str_num = 0; found = 0; temp = 0; printf("내면 ""EE""\n"); //. printf("료 -> %s", x); printf("\n 문 -> "); scanf("%s", search_str); fprintf(fp,"료 -> %s", x); //result.out . fprintf(fp, "\n 문 -> "); fprintf(fp, "%s", search_str); if(search_str[0] == 'E' && search_str[1] == 'E') break; exist_word(x, exist_str); found = compare_str(x, search_str, exist_str); switch(found){ case 1: fprintf(fp, "\nfirst found -> %d\n\n", exist_str[word_num]+1); break; case 0: fprintf(fp, "\nNot found!\n\n"); break; } } fclose(fp); } void exist_word(char x[40], int exist_str[10]) { int num = 2, x_n = 0; exist_str[1] = 0; while(x[x_n]) { if(x[x_n] == ' ') { exist_str[num] = x_n + 1; //빈 문 . ++num; } ++x_n; } } int compare_str(char x[40], char search_str[15], int exist_str[10]) { if(x[exist_str[word_num]] != search_str[search_str_num]) { ++word_num; if(exist_str[word_num] >= 0) compare_str(x, search_str, exist_str); }else{ temp = exist_str[word_num]; while(search_str[search_str_num]) { if(x[temp] == search_str[search_str_num]){ found = 1; ++temp; ++search_str_num; }else{ found = 0; break; } } } return found; }
C++ 문 . ¶
~cpp //cpp1.cpp #include <iostream> #include "class.h" using namespace std; void main() { Search_ch c; c.input(); c.search(); c.print(); }
~cpp //cpp2.cpp #include <iostream> #include "class.h" using namespace std; void Search_ch::input() { cin>>str; cin>>ch; } int Search_ch::search() { int i, str_len, k; str_len = strlen(str); for(i = 0; i <= str_len-1; i++) { if(str[i] == ch) { k = i; break; }else{ k = 0; } } return k; } void Search_ch::print() { int found_num = search(); if(found_num == 0){ cout << "Not Found!!"; }else if(0 < found_num && found_num < strlen(str)){ cout << "Found!! >>>" <<found_num+1; } }
~cpp //class.h class Search_ch { private: public: char str[20]; char ch; void input(); int search(); void print(); };