2022-08-03 算法学习——集合的遍历,同时推广到stl容器的遍历
include<bits/stdc++.h>
using namespace std;
set <int> st;
int n;
int main() {
scanf("%d",&n);
for(int i=0;i<n;i++) {
int tmp;
scanf("%d",&tmp);
st.insert(tmp);
}
//集合的遍历
for(auto it = st.begin();it!=st.end();it++) {
cout<<it<<endl;
}
//返回极差
set < int > ::iterator it= --st.end();
cout<<it - *st.begin();
return 0;
}

浙公网安备 33010602011771号