Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <list>
- using namespace std;
- void getPrimes(int begin, int end);
- int main () {
- list<string> cmplist;
- string input;
- int val[2];
- while(true)
- {
- getline(cin, input);
- if (!input.empty())
- cmplist.push_back(input);
- else
- {
- cmplist.begin();
- break;
- }
- }
- while (!cmplist.empty())
- {
- val[0] = 0, val[1] = 0;
- istringstream iss(cmplist.front(), istringstream::in);
- iss >> val[0];
- iss >> val[1];
- if (val[0] > 0 && val[1] > 0)
- getPrimes(val[0], val[1]);
- else
- cout << endl;
- cmplist.pop_front();
- }
- return 0;
- }
- void getPrimes (int begin, int end) {
- static vector<int> numlist;
- vector<int> foundlist;
- if (numlist.empty())
- numlist.push_back(2);
- if (numlist.back() < end)
- while(true)
- {
- //TODO: get primes here
- }
- for (int i = 0; i < numlist.size ; i++)
- {
- if (numlist.at(i) > begin && numlist.at(i) < end)
- foundlist.push_back(numlist.at(i));
- else if (numlist.at(i) > end)
- break;
- }
- for (int i = 0; i < foundlist.size(); i++)
- cout << foundlist.at(i) << endl;
- cout << endl;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement