본문 바로가기

언어

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 더보기
문자열~리스트~조건,반복문 #2중 for문으로 별찍기 for i in range(1,6): for j in range(1,6): if (j==i): print('*', end=' ') else: print(' ', end=' ') print(' ') #print() 줄바꿈 없는함수 print("my ", end=' ') print("dream ", end=' ') print("is ", end=' ') print("Programming ", end= ' ') #키보드로부터 글자입력받기 ''' message=input("글자를 입력하세요 ") print(message) numStr=input("숫자를 입력하세요") num=int(numStr) print(num*2) ''' #for (초기화; 조건; 증감) 이런 형태가 없음 for .. 더보기
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 더보기
4장 3번 - 문장입력하고 부분 문자 바꾸기 #include #include #include #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; srand( (unsigned)time(0) ); string alpa[26]={"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}; int cstr; int calp.. 더보기
4장 2번 - 가장 큰 수 찾기 #include using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ class Sample{ private: int *a; int num=10; public: Sample(int num){ a=new int[num]; } ~Sample(){ delete [] a; } void read(){ for(int i=0; i> a[i]; } } void write(){ for(int i=0; i 더보기