主题:[原创]递归九连环 (如果你会玩的话。。。)
#include "stdio.h"
#define N 9
void Dowm(int);
void Up(int);
void main()
{
Dowm(N);
}
void Dowm(int n)
{
if (n == 1)
{
printf("1 dowm\n");
}
else if(n == 2)
{
printf("1&2 dowm\n");
}
else
{
Dowm(n - 2);
printf("%d dowm\n", n);
Up(n - 2);
Dowm(n - 1);
}
}
void Up(int n)
{
if(n == 1)
{
printf("1 up\n");
}
else if(n == 2)
{
printf("1&2 up\n");
}
else
{
Up(n - 1);
Dowm(n -2);
printf("%d up\n", n);
Up(n - 2);
}
}
#define N 9
void Dowm(int);
void Up(int);
void main()
{
Dowm(N);
}
void Dowm(int n)
{
if (n == 1)
{
printf("1 dowm\n");
}
else if(n == 2)
{
printf("1&2 dowm\n");
}
else
{
Dowm(n - 2);
printf("%d dowm\n", n);
Up(n - 2);
Dowm(n - 1);
}
}
void Up(int n)
{
if(n == 1)
{
printf("1 up\n");
}
else if(n == 2)
{
printf("1&2 up\n");
}
else
{
Up(n - 1);
Dowm(n -2);
printf("%d up\n", n);
Up(n - 2);
}
}