convert nested loop to recursion

i have a codes like this
#include <iostream>
#include <conio.h>

using namespace std;

int main()
{

for(int a=1;a<6;a++)
{
for(int b=1;b<6;b++)
{
cout <<"*";
}
cout <<endl;
}
getch();
return 0;
}

its too complex for me to convert it to recursive form ,any idea how to convert it?
You can't like this. It needs to be in a separate function. And actually, that isn't complex at all...go read up recursive functions and you should be able to figure it out.
No need to do separation function ,i had figure it out ,here is the solution:

#include <iostream>
#include <conio.h>

using namespace std;

int b = 0;
int c = 0;
void Symbol(int a)
{
if(c>=a)
{return ;}

if(b>=a)
{
cout<<endl;
c++;
b = 0;
Symbol(a);
}
else
{
cout <<"#";
b++;
Symbol(a);
}
}


int main()
{
Symbol(5);
getch();
return 0;

}
Use [code][/code] tags please.
You should pass the counter values as argument in recursive function, you shouldn't have them as globals
Topic archived. No new replies allowed.