1.调用系统排序办法
#include<algorithm>
sort(a,a+n);
例如:a[10] = {3,12,4,45,23,17,34,16,24,89};
sort(a,a+10);
2.调用系统栈
#include<stack>
stack<int> st;
st.push(12);
st.push(13);
st.push(14);
st.push(15);
st.pop();//弹出栈顶值,但是没有返回值。
st.size();//返回栈大小。
st.empty();//判断栈是不是空的;
3.调用系统队列
#include<queue>
queue<int> qu;
qu. push(12);
qu.push(13);
qu.push(14);
qu.push(15);
qu.pop()//弹出队列第一个值。
qu.front();//返回第一个值,但是没有弹出。
qu.back()//返回最后个值,但是没有弹出。
qu.size()//返回队列大小。
qu.empty()//判断队列是不是空。
4.数组初始化办法
int a[10] ;
memset(a,0,sizeof(a));//将a数组都初始化为0;
5.调用next_permutation()进行全排序
#include<algorithm>
char a[3] = {'A','B','C'};
do{
cout<<a[0]<<" "<<a[1]<<" "<<a[3]<<endl;
} while(next_permutation(a,a+3));
输出结果:
A B C
A C B
B A C
B C A
C A B
C B A