kudos to major_smalls
here is my code anywho for anyone who wants it as reference
Code:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int userdays=1,coin=1,total_coins=0,i=0,k=0,temp=0;
vector<int> user_input,output;
cout <<"Enter the number of days: ";
while(userdays != 0 )
{
cin >> userdays;
user_input.push_back(userdays);
}
user_input.pop_back();
temp = user_input.size();
for(i = 0; i < temp;i++)
{
while(k < user_input[i])
{
for(int j = 0; j < coin;j++)
{
total_coins += coin;
k++;
if(k >= user_input[i])j=coin; //if k is greater than user days, quit loop
}
coin++;
}
output.push_back(total_coins); //at this point we push the total coins into the vector
total_coins=0; //reset the values of these vars to original
k=0;
coin=1;
}
for(int t = 0; t < temp; t++)cout<<"\nNumber of days: "<<user_input[t]<<endl<<"Number of coins at the end of those days: "<<output[t]<<"\n\n";
return 0;
}