c++ 객체지향 중간고사
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

c++ 객체지향 중간고사에 대한 보고서 자료입니다.

목차

없음

본문내용

t * const, int * const );
int main()
{
const int arraySize = 10;
int a[ arraySize ] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37 };
cout << "Data items in original order\n";
for( int i = 0; i < arraySize; i++ )
cout << setw( 4 ) << a[ i ];
/* “bubbleSort" 함수를 호출하여 배열 (array) “a"를 정렬 (sort) 한다. 함수 호출 (function call)을 쓰시오 */
bubbleSort( a, arraySize );
cout << "\nData items in ascending order\n";
for( int j = 0; j < arraySize; j++ )
cout << setw( 4 ) << a[ j ];
return 0;
}
// sort an array of integers using bubble sort algorithm
void bubbleSort( int *array, const int size )
{
// loop to control passes
for ( int pass = 0; pass < size - 1; pass++ )
{
// loop to control comparisons during each pass
for ( int k = 0; k < size - 1; k++ )
{
/* 다음의 조건이 참 (true)일 경우 배열 (array)의 두 엘리멘트 (element)를 교환 (swaping)하는 함수 "swap"을 function declaration (prototype)과 주어진 상황에 맞게 호출하시오. */
if ( array[ k ] > array[ k + 1 ] )
{
swap( &array[ k ], &array[ k + 1 ] );
}
}
}
}
/* 두 엘리멘트를 function declaration (prototype)과 주어진 상황에 맞게 입력 받아 교환하는 함수 “swap”의 definition을 작성하시오. */
void swap( int * const element1Ptr, int * const element2Ptr )
{
int hold = *element1Ptr;
*element1Ptr = *element2Ptr;
*element2Ptr = hold;
}

키워드

  • 가격1,000
  • 페이지수6페이지
  • 등록일2007.05.08
  • 저작시기2004.4
  • 파일형식한글(hwp)
  • 자료번호#408422
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니