#include <cstdlib>
#include <iostream>
#include <vector> //need for vectors
usingnamespace std;
int main()
{
int i, x=1, n=4;
vector<int> numbers; //used to store the values 1,5;
vector<int>::iterator output; //used to output results
for (i=1; i<6; i++)
{
numbers.push_back(i); //adds values to vector(numbers)
}
while (x <= numbers.size()) { //makes code run as many times as there are values in the vector
for (output=numbers.begin(); output < numbers.end() - n; output++) //subtracting n makes it run through an increasing amount of times (i think)
{
cout << *output;
}
x++; //used to keep track of how many times this runs
n--; //next time it outputs, it will output one more value of the vector
cout << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
The output you get from this looks like:
1
12
123
1234
12345
I know its not the whole thing, but its a start, and it's the extent of my High School Programming 1 class knowledge :P