?? lab10_2.cpp
字號:
// lab10_2.cpp
#include <algorithm>
#include <iostream>
#include <functional>
using namespace std;
void main()
{
int A[8] = { 5, 2, 7, 4, 4, 2, 6, 1 } ;
int *location ;
int i ;
int value ;
cout << "數組的值為:{ ";
for(i = 0; i < 7; i++)
cout << A[i] << ", " ;
cout << A[7] << "}" << endl ;
cout << "輸入想查找的數:";
cin >> value;
location = find(A, A + 8, value) ;
if (location != A + 8)
cout << "最先等于" << value << "的是第"
<< (location-A)+1 << "個元素" << endl;
else
cout << "沒有找到所查找的數。" << endl;
cout<<"排序前的結果:"<<endl;
copy(A,A+8,ostream_iterator<int>(cout," "));
cout<<endl;
sort(A,A+8);
cout<<"升序排列后的結果:"<<endl;
copy(A,A+8,ostream_iterator<int>(cout," "));
sort(A,A+8,greater<int>());
cout<<endl;
cout<<"降序排列后的結果:"<<endl;
copy(A,A+8,ostream_iterator<int>(cout," "));
cout<<endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -