Advertisement
Nattack

Untitled

Oct 18th, 2011
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. #include <vector>
  5. #include <list>
  6.  
  7. using namespace std;
  8.  
  9. void getPrimes(int begin, int end);
  10.  
  11. int main () {
  12. list<string> cmplist;
  13. string input;
  14. int val[2];
  15.  
  16. while(true)
  17. {
  18. getline(cin, input);
  19. if (!input.empty())
  20. cmplist.push_back(input);
  21. else
  22. {
  23. cmplist.begin();
  24. break;
  25. }
  26. }
  27.  
  28. while (!cmplist.empty())
  29. {
  30. val[0] = 0, val[1] = 0;
  31. istringstream iss(cmplist.front(), istringstream::in);
  32. iss >> val[0];
  33. iss >> val[1];
  34. if (val[0] > 0 && val[1] > 0)
  35. getPrimes(val[0], val[1]);
  36. else
  37. cout << endl;
  38. cmplist.pop_front();
  39. }
  40.  
  41. return 0;
  42. }
  43.  
  44. void getPrimes (int begin, int end) {
  45. static vector<int> numlist;
  46. vector<int> foundlist;
  47. if (numlist.empty())
  48. numlist.push_back(2);
  49. if (numlist.back() < end)
  50. while(true)
  51. {
  52. //TODO: get primes here
  53. }
  54. for (int i = 0; i < numlist.size ; i++)
  55. {
  56. if (numlist.at(i) > begin && numlist.at(i) < end)
  57. foundlist.push_back(numlist.at(i));
  58. else if (numlist.at(i) > end)
  59. break;
  60. }
  61. for (int i = 0; i < foundlist.size(); i++)
  62. cout << foundlist.at(i) << endl;
  63. cout << endl;
  64. return;
  65. }
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement