OH MY GOD IT'S THE BEST THING EVER
C++ BITCH code:
#include <iostream>
#include <stdlib.h>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
vector<int> PrimeFinder(int a, int b)
{
if(a == 1)
{
a++;
}
vector<int> primes;
for(int subject = a; subject <= b; ++subject)
{
if(subject == 2)
{
primes.push_back(subject);
}else
{
for(int divisor = 1; divisor <= subject; ++divisor)
{
if(divisor == subject)
{
primes.push_back(subject);
}else if(subject % divisor == 0 && divisor > 1)
{
break;
}
}
}
}
return primes;
}
int main()
{
vector< vector < vector <int> > > ohgod;
int itests;
cout << "Number of tests (<=10): ";
while(true)
{
string qtests;
getline(cin, qtests);
stringstream ssa(qtests);
if(ssa >> itests)
{
if(itests <= 10 && itests > 0)
{
ohgod.resize(itests);
for(int i = 0; i < itests; i++)
{
ohgod[i].resize(2);
ohgod[i][0].resize(2);
cout << "Test " << i + 1 << " limiters: ";
int icheck = 0;
while(icheck < ohgod[i][0].size())
{
vector<string> qlimits;
string a;
getline(cin, a);
int check;
stringstream ssi(a);
if(ssi >> check)
{
unsigned x = 0;
while(qlimits.size() < 2)
{
string b;
if(x == 0)
{
unsigned y = a.find(" ");
b = a.substr(x, y);
x = a.find(" ") + 1;
}else
{
b = a.substr(x);
}
qlimits.push_back(b);
++icheck;
}
for(int j = 0; j < qlimits.size(); j++)
{
int z;
stringstream ss(qlimits[j]);
if(ss >> z)
{
ohgod[i][0].at(j) = z;
}
}
if(qlimits.size() < 2)
{
cout << "Enter minumum AND maximum limiters: ";
qlimits.clear();
icheck = 0;
}else if(qlimits.size() > 2)
{
qlimits.resize(2);
}else if(ohgod[i][0][0] >= ohgod[i][0][1])
{
cout << "Minimum to maximum limits: ";
qlimits.clear();
icheck = 0;
}
if(icheck >= 2)
{
for(int j = 0; j < ohgod[i][0].size(); j++)
{
stringstream ssb(qlimits[j]);
int y;
if(ssb >> y)
{
ohgod[i][0].at(j) = y;
}
}
}
}else
{
cout << "Integral limiters only: ";
icheck = 0;
}
}
ohgod[i][1] = PrimeFinder(ohgod[i][0][0], ohgod[i][0][1]);
}
break;
}else if(itests >= 10)
{
cout << "Less than 10 tests: ";
}else
{
cout << "Must be a positive value: ";
}
}else
{
cout << "Integral test no.: ";
}
}
cout << endl;
for(int i = 0; i < ohgod.size(); ++i)
{
cout << "Test " << i + 1 << " (" << ohgod[i][0][0] << " to " << ohgod[i][0][1] << "):" << endl;
for(int j = 0; j < ohgod[i][1].size(); j++)
{
cout << ohgod[i][1].at(j);
if(j < (ohgod[i][1].size() - 1))
{
cout << ", ";
}else
{
cout << endl << endl;
}
}
}
return 0;
}
Last edited by Fear; May 30, 2013 at 08:02 PM.