본문 바로가기

언어/C++

5장 4번- Ogdol -> Okdol 단어 알파벳 바꾸기 #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ char& find(char a[], char c, bool& success); char& find(char a[], char c, bool& success){ for(int i=0; i 더보기
5장 2번- 더 큰 수 비교하기 (참조 매개변수) #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ bool bigger(int a, int b, int& big); bool bigger(int a, int b, int& big){ big=a; if(a 더보기
5장 1번 - 참조 매개변수 이용해서 swap #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ void swap(int &n,int &m){ int temp; temp=n; n=m; m=temp; }; int main(int argc, char** argv) { int a =1; int b= 10; cout 더보기
4장 10번 - 문장 알파벳 히스토그램 만들기 #include #include /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; class Histogram{ string his; int len; int count[26]; public: Histogram(string h){ his=h+"\n"; len=0; for(int i=0; i 더보기
4장 9번 - 원의 최소면적에 따라 원 분류 #include #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Circle{ int radius; string name; public: void setCircle(string name, int radius){ this->name=name; this->radius=radius; } double getArea(){ return radius*radius*3.14; } string getName(){ return name; } }; class CircleManager{ Circle *circle; int num; p.. 더보기
4장 7번 -이름으로 전화번호 검색하기 #include #include using namespace std; class Person { string name; string tel; public : string getName() { return name; } string getTel() { return tel; } void set( string name, string tel) { this->name = name; this->tel = tel; } }; int main() { int n; Person p[3]; string name, number; cout number; p[i].set( name, number); } cout > per >> pho; person[1].setName(per); person[1].setPhone(pho); cout.. 더보기
4장 5,6번 - 동적할당으로 원 반지름, 면적 구하기 #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Circle { int radius; public : void setRadius(int radius); double getArea(); }; void Circle::setRadius(int radius){ this->radius=radius; } double Circle ::getArea(){ return radius*radius*3.14; } int main(int argc, char** argv) { //Circle circle[3]; int count=0; .. 더보기
4장4번 - 문장 거꾸로 출력하기 #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char** argv) { string str; string first; string last; cout 더보기