# Thread: c programing recursion homework.

1. ## c programing recursion homework.

so i have a homework in recursion , i have to write a function that gets 2 scores of players, and print all the options to get the last score, every player can get 1 point or 2 points per single turn, i need it to with no loop use.

2. Please paste the code that you've currently written

3. Code:
```void Stanga()
{
int firstteam, socendteam;
firstteam = first_team_score();
socendteam = socend_team_score();
print_all_Stanga_options(0, 0, firstteam, socendteam);
}

int first_team_score()
{
int score;
printf("Enter the result of the 1st team(0-15):\n");
scanf("%d", &score);
if (score < 0 || score>15)
score = first_team_score();
return score;
}

int socend_team_score()
{
int score;
printf("Enter the result of the 2nd team(0-15):\n");
scanf("%d", &score);
if (score < 0 || score>15)
score = socend_team_score();
return score;
}

void print_all_Stanga_options(int printfirst, int printsocend, int firstteam, int socendteam)
{
printf("%d:%d ", printfirst, printsocend);
if (firstteam != printfirst)
print_all_Stanga_options(printfirst + 1, printsocend, firstteam, socendteam);

if (printsocend != socendteam)
print_all_Stanga_options(printfirst, printsocend + 1, firstteam, socendteam);

if (firstteam + 1 != printfirst && firstteam != printfirst)
print_all_Stanga_options(printfirst + 1, printsocend, firstteam, socendteam);

if (printsocend + 1 != socendteam && printsocend != socendteam)
print_all_Stanga_options(printfirst, printsocend + 1, firstteam, socendteam);

if (firstteam == printfirst && socendteam == printsocend)
printf("\n");

}```

the print_all_Stanga_options function dont realy work correctly

4. the pictures i added is what i want to get.

Code:
```int first_team_score()
{
int score;
printf("Enter the result of the 1st team(0-15):\n");
scanf("%d", &score);
if (score < 0 || score>15)
score = first_team_score();
return score;
}

int socend_team_score()
{
int score;
printf("Enter the result of the 2nd team(0-15):\n");
scanf("%d", &score);
if (score < 0 || score>15)
score = socend_team_score();
return score;
}```
You need to do recursion for input? I can put -1 as long as I want as a user of your program and get it to crash....

Also, if you're trying to learn recursion and recursive functions, this is not the right way. Try printing something like the Fibonacci sequence with recursion.

6. im okay with that code, those are for making sure i get numbers just betwen 1-15,,
my problem is with "voidprint_all_Stanga_options(intprintfirst, intprintsocend, intfirstteam, intsocendteam)" is these int enogh for me ? and what i need to change to get the output in the pictures i added.

7. Code:
```void print_all_Stanga_options(int printfirst, int printsocend, int firstteam, int socendteam)
{
if (firstteam == printfirst && socendteam == printsocend)
{
printf("%d:%d ", printfirst, printsocend);
printf("\n");
}
if (printfirst < firstteam)
{
printf("%d:%d ", printfirst, printsocend);
print_all_Stanga_options(printfirst + 1, printsocend, firstteam, socendteam);
//if (printfirst > 0)
//	printfirst = printfirst - 1;
}
if (printfirst + 1 < firstteam)
{
printf("%d:%d ", printfirst, printsocend);
print_all_Stanga_options(printfirst + 2, printsocend, firstteam, socendteam);
//if (printfirst > 1)
//	printfirst = printfirst - 2;
}
if (printsocend < socendteam)
{
printf("%d:%d ", printfirst, printsocend);
print_all_Stanga_options(printfirst, printsocend + 1, firstteam, socendteam);
//if (printsocend > 0)
//	printsocend = printsocend - 1;
}
if (printsocend + 1 < socendteam)
{
printf("%d:%d ", printfirst, printsocend);
print_all_Stanga_options(printfirst, printsocend + 2, firstteam, socendteam);
//if (printsocend > 1)
//	printsocend = printsocend - 2;
}
}```
thats what i have done, im not sure what have to done next.