[Solved] permutation and combinations football score


Simple answer to use recursion, If you don’t know recursion read that first

void print_goals(int m,int n,int i,int j,string s)
{
    if(i == m && j == n)
    {
      cout<<s+char(48+i)+'-'+char(48+j)<<endl;
      return;
    }
    if(i<=m)
    print_goals(m,n,i+1,j,s+char(48+i)+'-'+char(48+j)+',');
    if(j<=n)
    print_goals(m,n,i,j+1,s+char(48+i)+'-'+char(48+j)+',');



}

call it as print_goals(5,2,0,0,"");
where m=5 and n=2

0

solved permutation and combinations football score