+ 3
Just and only prime numbers such as 1,3,5,7,11,13,17,21,23,27,31,33,37,41,.....till..97
Which loop
5 odpowiedzi
+ 5
Why'd you post the question again Mahendra Kumar ?
https://www.sololearn.com/Discuss/1292931/?ref=app
+ 4
#include <iostream>
#include <vector>
using namespace std;
template<typename T>
void removeVectorElement(std::vector<T> &vec, unsigned int at){
if(at == 0) vec.erase(vec.begin());
else vec.erase(vec.begin() + at);
}
int main() {
std::vector<int> vec_prime;
int maxPrimeNumber;
cout << "Enter the number of prime up to: ";
cin >> maxPrimeNumber ;
cout << maxPrimeNumber << endl;
for (int s = 2; s <= maxPrimeNumber; s++)
vec_prime.push_back(s);
for (int prime : vec_prime){
for (int i = 0; i < vec_prime.size(); i++){
if (vec_prime[i] % prime == 0 && prime != vec_prime[i]){
removeVectorElement(vec_prime, i);
}
}
}
cout << endl << "The prime numbers are: " << endl;
for (auto d : vec_prime)
cout << d << " ";
cout << endl;
return 0;
}
+ 2
مفيش حد مصري هنا ساعدونا يا جماعه
+ 1
for loop