Hello everyone, I have a little request, I know that many of you frown upon such things, but..I have nowhere else to turn, in short: if I don't pass this test I'm not getting my high-school diploma tomorrow, please I beg you to help me solve this
"write a program that will format true random sequence a0, a1, ..... a100n, values [-A, B] segment, where A = k, B = 2 * k * n, k-ticket number, n - your number. sort descending Order obtained by using a simple insertion algorithm to classify moving and print largest 2nd element."
if I don't pass this test I'm not getting my high-school diploma tomorrow
You should have studied and practiced more. The real world is not going to be so nice. If you can't do the job or even put forth effort, then you're fired. Nobody is going to do this for you. We'll be glad to help, but you have to show us work that you have already done with this.
It's also weird that a high school student needs a programming class to graduate. Is that part of the required curriculum now??
Weird didn't know high school kids graduated this early lol its barely spring.
Anyways show us what you have so far, and we will work WITH YOU to figure it out. We won't just do it for it so if that is what your asking you might as well just forget it.
So post what you have so far and where you are stuck at, what problems you have run into, what you have tried, anything you don't understand, ect. Also remember to use codetags (Highlight code then press the <> under format) when posting your code.
Then we can help guide you to getting the problem solved.
Yeah I live in a foreign country more specifically Georgia where we graduate around this time(well a month later, but testing is tomorrow)
So far I have NOTHING, but that is not due to me being lazy, I just have no idea where to begin the most complex thing I can do in C++ in print out odd and even numbers and do a basic loop.
Well then get reading and start coding. I highly doubt they would have just gave you this problem and told you that if you don't pass it you will not graduate without teaching you how to do it. I mean this isn't exactly beginner "Hello World" stuff.
Not trying to be rude or anything.
Try and code it yourself for a hour then come back here with what you have. We won't care if it is no where near as close just as long as you try. After we see the code we can tell you what you will need to study, what you need to learn, and what you did wrong. We will even probably provide you some links to resources you can use for each subject you are struggling on.
So get coding we won't do it for you, its not our ass that is on the line.
Interesting, I had no idea there was a country called Georgia.
I think it was part of the soviet union or something. At least that is what I have heard about it before.
Alright Zereo I'll do my best
I appreciate the fact that you're even replying to me but I don't really have time to read any documentation, not trying to come off as rude, and I know this is a common excuse, but our teacher is extremely bad at explaining things, the evidence is that 18 kids out of 20 failed his "pseudo exam"
It's really hard to comprehend what he's saying or what he has written, I'll try to find a solution and post here.
#include <time.h> // You need this for the time() function
for (int i = 0; i != 10; ++i)
int randomInt = rand();
cout << randomInt << endl;
What it does is passes a seed to srand() from what is return from time(). This will give you semi random numbers.
srand() info can be found here - http://www.cplusplus.com/reference/cstdlib/srand/
time() info can be found here - http://www.cplusplus.com/reference/ctime/time/
rand() info can be found here - http://www.cplusplus.com/reference/cstdlib/rand/
I know you say you don't have time to read documentation but you are going to have to. So get ready to pull a all nighter.
Sort each number you generate in a container, personally I prefer vector<int> over list unless you are going to be doing a lot of insertion in the middle and deletion in the middle. If you use a list you won't have random access to the numbers either.
#include <vector> // Needed for vector<>
#include <algorithm> // Needed for sort()
vector<int> numbers; // Our containers to store all the numbers
for (int i = 0; i != 10; ++i)
int randomInt = rand() % 100 + 1; // Generates a number 1 - 100
cout << randomInt << endl; // Prints the number
numbers.push_back(randomInt); // This will put the number on the
// back of the vector
cout << "\n\n\n";
// This will sort the vector from smallest to largest.
// numbers.begin() is a pointer to the first element in the vector
// and numbers.end() is pointer the last element in the vector
// Basically you are telling it to sort from the first to the last element
// Prints everything in the vector
for (int i =0; i != numbers.size(); ++i)
cout << numbers[i] << endl;