C++ ESPRESSO(에스프레소) PART 03 - CHAPTER 11 PROGRAMMING(프로그래밍) 5개
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

C++ ESPRESSO(에스프레소) PART 03 - CHAPTER 11 PROGRAMMING(프로그래밍) 5개에 대한 보고서 자료입니다.

본문내용

----------------------"< }
};
int main()
{
Stack s;
try{
s.push(3);
s.display();
s.push(4);
s.display();
s.pop();
s.display();
s.pop();
s.display();
s.pop();
//s.display();
}
catch(char *e)
{
cout< }
return 0;
}
4. 성적을 처리하는 클래스 ProcessScore를 작성하라.
#include
using namespace std;
class ProcessScore{
double average;
public:
ProcessScore(int *p, int index)
{
int tmp=0;
for(int i=0; i< index; i++)
{
if((*p) < 0) throw "IllegalScoreException";
tmp+= *p;
p++;
}
average = tmp / 5.0;
}
void display()
{
cout<<"평균 점수는 : "< }
};
int main()
{
int score[5]={10,20,-30,40,50};
try{
ProcessScore p(score, 5);
p.display();
}
catch(char *e)
{
cout< }
return 0;
}
5. 숫자를 저장하고 있는 배열을 받아서 지정된 숫자를 찾는 SearchArray를 작성하라.
#include
using namespace std;
class NotFound
{
public:
void display(){cout<<"NotFound"< };
class SearchArray
{
int index;
int *ptr;
public:
SearchArray(int *p, int i)
{
ptr = p;
index = i;
}
void searchNum(int num)
{
int *tmp = ptr;
for(int i=0; i< index ; i++){
if(*tmp == num)
{
cout< break;
}
tmp++;
}
if(i == index) throw NotFound();
}
void display()
{
int *p = ptr;
cout<<"배열에 저장된 값은... " < for(int i=0; i< index ; i++)
{
cout<<"["<<*p<<"] ";
p++;
}
cout< }
};
int main()
{
int input=0;
int s[10]={11,22,33,44,55,66,77,88,99,111};
SearchArray sa(s, 10);
try{
sa.display();
cout<<"찾을 값을 입력하세요 : ";
cin>>input;
sa.searchNum(input);
}
catch (NotFound& e)
{
e.display();
}
return 0;
}
  • 가격2,300
  • 페이지수7페이지
  • 등록일2014.11.04
  • 저작시기2012.4
  • 파일형식한글(hwp)
  • 자료번호#945469
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니