gautam chavan
BAN USERint n = 10;
int nthNum = 1;
for (int i = 1, j = 0; j < n; i++)
{
if ((0 == i % 28) || ((0 != i % 4) && (0 != i % 7)))
{
nthNum = i;
j++;
}
}
cout << n << "th number is" << nthNum << endl;
void Spacify(char* input)
{
if (!input)
return;
int writeIndex = 0;
int len = strlen(input);
char currChar = '\0';
for (int i = 0; i < len; i++)
{
currChar = input[i];
// check for starting of a word
if (!isspace(currChar))
{
// copy the whole word
while (i < len && !isspace(currChar))
{
char temp = input[writeIndex];
input[writeIndex] = currChar;
input[i] = temp;
writeIndex++;
i++;
currChar = input[i];
}
if (writeIndex < len)
{
input[writeIndex] = ' ';
writeIndex++;
}
}
}
}
this line inputChars[i++] = ' '; overrides the null character at the end for any string that ends with a character instead of a space. e.g. "Hello World".
- gautam chavan July 19, 2014
void PrintSubsets(int n, int currSum, vector<int>& combinations)
- gautam chavan March 21, 2015{
if (n == currSum)
{
for (auto item : combinations)
cout << item << " ";
cout << endl;
return;
}
for (int i = 1; i <= (n - currSum); i++)
{
if ((currSum + i) <= n)
{
combinations.push_back(i);
PrintSubsets(n, currSum + i, combinations);
combinations.pop_back();
}
}
}