pex8_4.cpp
来自「数据结构C++代码,经典代码,受益多多,希望大家多多支持」· C++ 代码 · 共 38 行
CPP
38 行
#include <iostream.h>
#include <stdlib.h>
#pragma hdrstop
#include "wex8_12.h"
#include "arrsort.h"
void main(void)
{
// safe array of 10 integers
ArrCL<int> A(10);
// read 10 values
for (int i = 0; i < 10; i++)
cin >> A[i];
// sort the safe array by using the pointer conversion operator
// in the call to the already written exchange sort function
ExchangeSort((int *)A,10);
// print the sorted array
for (i = 0; i < 10; i++)
cout << A[i] << " ";
cout << endl;
// 10 is an invalid index. program will terminate
cout << A[10] << endl;
}
/*
<Run>
1 5 4 3 2 6 7 9 8 0
0 1 2 3 4 5 6 7 8 9
Index out of range: 10
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?