No older revisions available
No older revisions available
첫번째 ¶
문자입력받은후 거꾸로 출력
이어서 출력
내용바꾸기 뭔말인지 ㅋ
이어서 출력
내용바꾸기 뭔말인지 ㅋ
Mystring.h ¶
~cpp class Mystring { private: char ch[20]; public: void reverse(); void input(); void show(); void search(); void change(); void add(); };
Mystring.cpp ¶
~cpp #include <iostream> using namespace std; #include "MyString.h" void Mystring::reverse() { int len; for (int i=0; i<=20; i++){ if(ch[i]=='\0'){ len=i; break; } } for(i=len-1; i>=0; i--){ cout << ch[i]; } } void Mystring::input(){ cin >> ch; } void Mystring::show(){ cout << ch; } void Mystring::search(){ char cha; cin >> cha; int len; for (int i=0; i<=20; i++){ if(ch[i]==cha){ len=i; break; } } cout << len+1; } void Mystring::change(){ char newch[20]; cin >> newch; for(int i=0; i<20; i++){ ch[i]=newch[i]; } } void Mystring::add(){ char newch[20]; cin >> newch; cout << ch; cout << newch; }