迭代器
Posted 俺叫王梦涵
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了迭代器相关的知识,希望对你有一定的参考价值。
#include<cmath> #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<string> #include<stack> #include<queue> #include<map> #include<cstdlib> #include<set> #include<ctime> #include<vector> #include<cstdio> #include<list> #include<sstream> //#include<regex> using namespace std; typedef long long ll; int INF=2147483647; int inf=-2147483648; #define read(x) scanf("%d",&x); #define fo(i,n) for(int i=0;i<(n);i++) #define me(a) memset(a,0,sizeof(a)); #define one(x) cout<<(x)<<endl; #define two(a,b) cout<<(a)<<" "<<(b)<<endl; #define three(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl; #define four(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl; //int dir[4][2]={-1,0,1,0,0,-1,0,1}; //int dir[8][2]={-1,0,1,0,0,-1,0,1,-1,-1,1,1,1,-1,-1,1}; //int dir[4][2]={-2,0,2,0,0,-2,0,2}; const double PI = acos(-1.0); int prime(int n){ for(int i=2;i<=sqrt(n);i++) if(n%i==0) return 0; return 1; } int main() { ios::sync_with_stdio(false); int n; set<int>q; cin>>n; for(int i=2;i<=n;i++){ if(prime(i)){ for(int j=i;j<=n;j*=i){ q.insert(j); } } } cout<<q.size()<<endl; set<int>::iterator it; for(it=q.begin();it!=q.end();it++){ cout<<*it<<" "; } cout<<endl; return 0; }
以上是关于迭代器的主要内容,如果未能解决你的问题,请参考以下文章