Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

func solve(a, b, c int) int {
	if a == 1 && b >= c && b < 10 {
		return 1
	}
	if a == 1 {
		return 0
	}
	ret := 0
	for i := c; i < 10 && i < b; i++ {
		ret += solve(a-1, b-i, i+1)
	}
	return ret
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		if a == 0 {
			break
		}
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())
		fmt.Println(solve(a, b, 0))
	}
}

C++: #include<iostream>
using namespace std;
int syu(int *p,int n){
  int s=0;
  for(int i=0;i<n;i++) s += p[i];
  return s;
}
int main(){
  int n,s;
  while(cin>>n>>s){
    if(n==0&&s==0) break;
    int p[n],count=0;
    for(int a=0;a<=9;a++){
      p[0] = a;
      if(n==1&&syu(p,n)==s){
 count++;
 continue;
      }
      for(int b=a+1;b<=9;b++){
 p[1] = b;
 if(n==2&&syu(p,n)==s){
   count++;
   continue;
 }
 for(int c=b+1;c<=9;c++){
   p[2] = c;
   if(n==3&&syu(p,n)==s){
     count++;
     continue;
     for(int d=c+1;d<=9;d++){
       p[3] = d;
       if(n==4&&syu(p,n)==s){
  count++;
  continue;
  for(int e=d+1;e<=9;e++){
    p[4] = e;
    if(n==5&&syu(p,n)==s){
      count++;
      continue;
      for(int f=e+1;f<=9;f++){
        p[5] = f;
        if(n==6&&syu(p,n)==s){
   count++;
   continue;
   for(int g=f+1;g<=9;g++){
     p[6] = g;
     if(n==7&&syu(p,n)==s){
       count++;
       continue;
     }
     for(int h=g+1;h<=9;h++){
       p[7] = h;
       if(n==8&&syu(p,n)==s){
         count++;
         continue;
       }      
       for(int i=h+1;i<=9;i++){
         p[8] = i;
         if(n==9&&syu(p,n)==s){
    count++;
    continue;
         }
       }
     }
   }
        }
      }
    }
  }
       }
     }
   }
 }
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;

int a[10] = { 0,1,2,3,4,5,6,7,8,9 };
int n, s,r;

void dfs(int i, int sum,int n) {
	if (!n&&sum == s) {
		r++;
		return;
	}
	if (i == 10 || !n)return;
	dfs(i + 1, sum,n);
	dfs(i + 1, sum + a[i],n-1);
	return ;
}

int main() {
	while (cin >> n >> s, n, s) {
		r = 0;
		dfs(0, 0,n);
		cout <<r << endl;
	}
	return 0;

}

C++: import java.util.*;
public class Main {
	static int ans,n;
	
	//nowN->現在の足した回数  Sum->足した合計値  before->前の数
	static int dfs(int nowN, int Sum, int before) {
		int count = 0;
		if(Sum > ans) return(0);
		
		if(nowN == n) {
			if(Sum == ans) return(1);
			else           return(0);
		}
		for(int r = before; r < 10; r++) {
			count += dfs(nowN + 1, Sum + r, r + 1);
		}
		return(count);
	}
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		n = -1;
		ans = -1;
		while(ans != 0 && n != 0) {
			n = stdIn.nextInt();
			ans = stdIn.nextInt();
			if(n == 0 && ans == 0) break;
			
			int result = dfs(0, 0, 0);
			System.out.println(result);
			
		}
		
	}

}

C++: #include <iostream>using namespace std;
 int dfs(int n, int s, int x){
    int sum=0;
    if(n==0 && s==0)
    return 1;
    if(n>0){
        for(int i=x; i<10; i++){
            if(s-i>=0)  sum+=dfs(n-1, s-i, i+1);
        }
    }

    return sum;
}
 int main(void){
    int n, s;
    while(cin >> n >> s){
        if(n==0 && s==0)
    break;
        cout << dfs(n, s, 0) << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int n,s,count;

int solve(int i,int sum,int used){
	
	if(i==10){
		if(s==sum&&used==n){
		 count++;
		}
		return count;
	}
	solve(i+1,sum+i,used+1);
	
	solve(i+1,sum,used);
	
	return count;
}

int main(){
	
	while(cin>>n>>s,n&&s){
	count=0;
	cout<<solve(0,0,0)<<endl;
	}

return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
int n,s,R;
while(cin>>n>>s&&n!=0||s!=0)
{
R=0;
	if(n>=1)
	{
		for(int j=0;j<10;j++)
		{	
			if(n>=2)
			{
				for(int k=j+1;k<10;k++)
				{		
					if(n>=3)
					{
						for(int l=k+1;l<10;l++)
						{
							if(n>=4)
							{
								for(int m=l+1;m<10;m++)
								{	
									if(n>=5)
									{
										for(int o=m+1;o<10;o++)
										{
										if(n>=6)
										{
											for(int p=o+1;p<10;p++)
											{
												if(n>=7)
												{
													for(int q=p+1;q<10;q++)
													{
														if(n>=8)
														{
															for(int r=q+1;r<10;r++)
															{
																if(n>=9)
																{
																		for(int t=q+1;t<10;t++)
																		{
																		if(j+k+l+m+o+p+q+r+t==s)
																		{
																		R++;	
																		}	
																		}
																	}
																	else if(j+k+l+m+o+p+q+r==s)
																	{
																	R++;	
																	}
																}
															}
															else if(j+k+l+m+o+p+q==s)
															{
															R++;	
															}
														}
													}
													else if(j+k+l+m+o+p==s)
													{
													R++;	
													}
												}	
											}
											else if(j+k+l+m+o==s)
											{
											R++;	
											}
										}
									}
									else if(j+k+l+m==s)
									{
									R++;	
									}
								}
							}
							else if(j+k+l==s)
							{
							R++;	
							}
						}				
					}
					else if(j+k==s)
					{
					R++;	
					}	
				}	
			}
			else if(j==s)
			{
			R++;	
			}	
		}
	}
cout<<R<<endl;
}
return 0;
}

C++: #include <iostream> 

int main(){
	int a,b;	
	while(std::cin>>a>>b&&a!=0&&b!=0){
		int d2=0,d3=0,d4=0,d5=0,d6=0,d7=0,d8=0,d9=0;
		int o=0;
		for(int d=0;d<10;d++){
			if(a>1&&d<=10-a){
				for(d2=d+1;d2<10;d2++){
			if(a>2&&d2<=10-a+1){
				for(d3=d2+1;d3<10;d3++){
			if(a>3&&d3<=10-a+2){
				for(d4=d3+1;d4<10;d4++){
			if(a>4&&d4<=10-a+3){
				for(d5=d4+1;d5<10;d5++){
			if(a>5&&d5<=10-a+4){
			for(d6=d5+1;d6<10;d6++){
			if(a>6&&d6<=10-a+5){
				for(d7=d6+1;d7<10;d7++){
			if(a>7&&d7<=10-a+6){
				for(d8=d7+1;d8<10;d8++){
			if(a>8&&d8<=10-a+7){
				for(d9=d8+1;d9<10;d9++){
		if(a==9&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==8&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==7&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==6&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==5&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		if(a==4&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==3&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}if(a==2&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
		}
		if(a==1&&b==d+d2+d3+d4+d5+d6+d7+d8+d9){
			o++;
		}
			}
		}
		std::cout<<o<<std::endl;
	}
}

C++: #include <iostream>
using namespace std;

int bit_count( const int n )
{
	int cnt = 0;
	int tmp = n;
	while ( tmp )
	{
		cnt ++;
		tmp &= tmp - 1;
	}
	return cnt;
}

int main( void )
{
	int d[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

	int n, s;
	while ( cin >> n >> s && n && s )
	{
		int answer = 0;
		for ( int i = 0; i < 1 << 10; i++ )
		{
			if ( bit_count( i ) == n )
			{
				int sum = 0;
				for ( int j = 0; j < 10; j++ ) if ( i & ( 1 << j ) ) sum += d[j];
				if ( sum == s ) answer++;
			}
		}
		cout << answer << endl;
	}

	return 0;
}