주석문의입니다
월식
음 주석자체가이해가안되네여 소스가
소스주석을 모두 알고싶습니다 공부해야죠..
쉽게 소스 좀 달아주세요
// usingstllist.cpp : stl list 컨테이너의 사용
#include iostream
#include list
using namespace std;
class point {
public:
int m_x, m_y;
point(int x = 0, int y = 0)
: m_x(x), m_y(y)
{
}
void print() const
{
cout ( m_x , m_y );
}
};
class shape {
protected:
point m_start, m_end;
public:
shape();
shape(int x1, int y1, int x2, int y2);
void setstartpoint(int x, int y);
void setendpoint(int x, int y);
virtual void draw() const = 0;
};
shape::shape()
{
}
shape::shape(int x1, int y1, int x2, int y2)
: m_start(x1, y1), m_end(x2, y2)
{
}
void shape::setstartpoint(int x, int y)
{
m_start.m_x = x;
m_start.m_y = y;
}
void shape::setendpoint(int x, int y)
{
m_end.m_x = x;
m_end.m_y = y;
}
class rectangle : public shape
{
public:
rectangle();
rectangle(int x1, int y1, int x2, int y2);
int getwidth() const;
int getheight() const;
void draw() const;
};
rectangle::rectangle()
{
}
rectangle::rectangle(int x1, int y1, int x2, int y2)
: shape(x1, y1, x2, y2)
{
}
int rectangle::getwidth() const
{
int width = m_end.m_x - m_start.m_x;
return width 0 ? width : -width;
}
int rectangle::getheight() const
{
int height = m_end.m_y- m_start.m_y;
return height 0 ? height : -height;
}
void rectangle::draw() const
{
cout rectangle 그리기 : ;
m_start.print();
cout -- ;
m_end.print();
cout , 가로= getwidth() , 세로= getheight() \n;
}
class ellipse : public shape
{
public:
ellipse();
ellipse(int x1, int y1, int x2, int y2);
bool iscircle() const;
void draw() const;
};
ellipse::ellipse()
{
}
ellipse::ellipse(int x1, int y1, int x2, int y2)
: shape(x1, y1, x2, y2)
{
}
bool ellipse::iscircle() const
{
int width = m_end.m_x - m_start.m_x;
int height = m_end.m_y - m_start.m_y;
return (width == height);
}
void ellipse::draw() const
{
cout ellipse 그리기 : ;
m_start.print();
cout -- ;
m_end.print();
if( iscircle() )
cout == 원\n;
else
cout == 타원\n;
}
int main()
{
listshape* list1;
while(true)
{
int choice;
cout 도형의 종류 선택 (1. 직사각형 2. 타원 0. 종료) : ;
cin choice;
if( choice == 0 )
break;
if( choice 0 || choice 2 )
{
cout 잘못 입력하셨습니다.\n;
continue;
}
switch( choice )
{
case 1:
list1.push_back(new rectangle);
break;
case 2:
list1.push_back(new ellipse);
break;
}
int x, y;
cout 도형의 시작점 입력 : ;
&; cin x y;
shape*& pshape = list1.back();
pshape-setstartpoint(x, y);
cout 도형의 끝점 입력 : ;
cin x y;
pshape-setendpoint(x, y);
}
listshape*::iterator it;
for(it = list1.begin() ; it != list1.end() ; ++it)
(*it)-draw();
for(it = list1.begin() ; it != list1.end() ; ++it)
delete (*it);
return 0;
}
---------------------------------------------------------------------------------------------------
// countwords.cpp
#include iostream
#include string
#include map
using namespace std;
int main()
{
string s;
mapstring, int words;
cout 문자열을 입력하세요. 종료하려면 ctrl+z을 입력하세요.\n;
while( cin s )
words[s]++;
mapstring, int::iterator it;
for(it = words.begin() ; it != words.end() ; ++it)
cout it-first : it-second 번\n;
return 0;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2696504 | 플래시 위에 div 올리기 (5) | 큰꽃늘 | 2025-05-30 |
2696458 | 제가 만든 소스 한번 봐주시고 수정 할 꺼 있으면 말해주세요. (실행은 되지만 깜빡거리네요) | 이플 | 2025-05-29 |
2696434 | 퍼센트 레이아웃 질문인데요.. | 나츠 | 2025-05-29 |
2696372 | %=open_main%, %=open_sub% 가 뭘까요? (9) | 행복녀 | 2025-05-29 |
2696347 | 콘솔 프로그램 질문 | 상큼한캔디 | 2025-05-28 |
2696320 | c언어 scanf 함수를 이요해 문자열 입력 받을 시 질문 있습니다. | 슬아라 | 2025-05-28 |
2696292 | 익스플로러9이상에서만 이상한 보더가 보이는데 삭제할수 있나요? | 망고 | 2025-05-28 |
2696263 | 프로그래밍 공부시작 질문 (6) | 진이 | 2025-05-28 |
2696206 | SK2의 플래시를 밴치마킹하려고하는데요.. (1) | 비내리던날 | 2025-05-27 |
2696179 | ie7에서 사라지지가 않네요. (2) | 빛길 | 2025-05-27 |
2696150 | div에 스크롤 생기게 하려면... (2) | 에드가 | 2025-05-27 |
2696123 | 자료구조론 공부중인데 | 김자영 | 2025-05-26 |
2696094 | exe 파일 | 제철 | 2025-05-26 |
2696043 | 제이쿼리 .scroll() 관련 질문드립니다 | 이거이름임 | 2025-05-26 |
2695984 | 마크업상으로 하단에 있으나 우선적으로 이미지파일을 다운로드받는 방법 (1) | 들꿈 | 2025-05-25 |
2695934 | tr 속성값 (9) | 새 | 2025-05-25 |
2695905 | ASP로 개발됐을 때 css가 달라져요 ㅠㅠ (4) | 슬아라 | 2025-05-24 |
2695878 | form을 이용한 다른 페이지로 넘기는 방법을 알려주세요 (1) | 핫파랑 | 2025-05-24 |
2695844 | 저기 암호화 및 복호화 프로그램.. 만들어볼려는대 (2) | 한빛 | 2025-05-24 |
2695814 | [질문] PDA에서 애플릿이 가능한가요? (1) | 봄시내 | 2025-05-24 |