Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int maxValor = 100;
- int repetiu;
- vector<int> tabela;
- vector<int> ignorar_valores;
- //popular o vector
- for(int x = 1; x <= maxValor; x++)
- tabela.push_back(x);
- //verifica quais valores devem ser retirados de tabela posteriormente
- for(unsigned int i = 1; i < tabela.size(); i++){
- for(unsigned int j = (i+1); j < tabela.size(); j++){
- if(tabela[j] % tabela[i] == 0)
- ignorar_valores.push_back(tabela[j]);
- }
- }
- //verifica se o valor em tabela[h] deve ser ignorado
- for(unsigned int h = 1; h < tabela.size(); h++){
- unsigned int j = 0;
- repetiu = 0;
- for(; j < ignorar_valores.size(); j++){
- if(tabela[h] == ignorar_valores[j]){
- repetiu++;
- }
- }
- if(repetiu == 0){
- cout << tabela[h] << ' ' ;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement