#include "stdafx.h"
#include<iostream>
#include<iterator>
#include<vector>
#include<cstdlib> //for srand and rand
usingnamespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int a,b,c,d,e,f,g,h,i,j;
cout << "Welcome to create that phone number" << endl;
cout << "Please enter a number 1-9 that is the first number" << endl;
cin >> a;
cout << "Please enter a number 1-9 that is the second number" << endl;
cin >> b;
cout << "Please enter a number 1-9 that is the third number" << endl;
cin >> c;
cout << "Please enter a number 1-9 that is the fourth number" << endl;
cin >> d;
if (d %2 != 0)
{
e = 0;
}
else
{
e = 1;
}
do
{
for (e = 1; e < 10; e++);
{
for (f = 1; e < 10; e++);
{
for (g = 1; e < 10; e++);
{
for (h = 1; e < 10; e++);
{
for (i = 1; e < 10; e++);
{
for (j = 1; e < 10; e++);
}
}
}
}
}
}
while ('e' + 'f' + 'g' + 'h' + 'i'+ 'j' == 33);
{
cout << "Phone number is" << a << b << c << d << e << f << g << h << i << j << endl;
}
system("pause");
return 0;
}
How exactly did you plan to get this thing to create a recursion? I don't see anything being done in the for-loops and there is not recursion going on here, just a lot of for-loops. Why are the numbers on line 56 in single quotes? After your last for-loop runs, everything stops because e will be 10 since that is your condition for the other loops. Line 56 also will most likely not run because since you only incremented e to 10, if the other numbers plus e is not equal to 33, it stops.
You have to rethink your algorithm because it is very flawed at this point
#include <iostream>
#include <cstdio>
#include <cstdlib> //for srand and rand
usingnamespace std;
int main(int nNumberofArgs,char* pszArgs[])
{
int a,b,c,d,e,f,g,h,i,j = 0;
cout << "Welcome to create that phone number" << endl;
cout << "Please enter a number 1-9 that is the first number" << endl;
cin >> a;
cout << "Please enter a number 1-9 that is the second number" << endl;
cin >> b;
cout << "Please enter a number 1-9 that is the third number" << endl;
cin >> c;
cout << "Please enter a number 1-9 that is the fourth number" << endl;
cin >> d;
for(int n = 0;n < 60;n++)
{
for (e = 0; e < 9; e++);
{
if(e + f + g + h + i + j == 33)
{
cout << "Phone number is " << a << b << c << "-" << d << e << f << "-" << g << h << i << j << endl;
}
for (f = 0; f < 9; f++);
{
if(e + f + g + h + i + j == 33)
{
cout << "Phone number is " << a << b << c << "-" << d << e << f << "-" << g << h << i << j << endl;
}
for (g = 0; g < 9; g++);
{
if(e + f + g + h + i + j == 33)
{
cout << "Phone number is " << a << b << c << "-" << d << e << f << "-" << g << h << i << j << endl;
}
for (h = 0; h < 9; h++);
{
if(e + f + g + h + i + j == 33)
{
cout << "Phone number is " << a << b << c << "-" << d << e << f << "-" << g << h << i << j << endl;
}
for (i = 0; i < 9; i++);
{
if(e + f + g + h + i + j == 33)
{
cout << "Phone number is " << a << b << c << "-" << d << e << f << "-" << g << h << i << j << endl;
}
for (j = 0; j < 9; j++);
{
if(e + f + g + h + i + j == 33)
{
cout << "Phone number is " << a << b << c << "-" << d << e << f << "-" << g << h << i << j << endl;
}
}
}
}
}
}
}
}
system("PAUSE");
return 0;
}