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>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){

  int n,s;
  int plus,sum,ans;
  bool retu[10];

  while(cin >> n >> s){
    if(n==0 && s==0)
      break;
    ans = 0;

    int sub = pow(2,n) - 1;
    int au = 0;
    for(int i=0;i<n;i++)
      au += pow(2,9-i);

    for(plus=sub;plus<=au;plus+=sub){
      for(int i=9,j=512,a=plus;i>=0;i--,j/=2){
	if(a/j==1){
	  a -= j;
	  retu[i] = true;
	}
	else
	  retu[i] = false;
      }
      sum = 0;
      for(int i=0;i<10;i++)
	if(retu[i] == true)
	  sum += i;
      if(sum==s)
	ans++;
    }
    cout << ans << endl;
  }

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

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

int n, s;

int part(int index, int count, int sum){
	if(index == 10){
		if(count == n && sum == s){
			return 1;
		}
		return 0;
	}
	return part(index + 1, count, sum) + part(index + 1, count + 1, sum + a[index]);
}

int main(){
	
	while(true){
		
		cin >> n >> s;
		
		if(n == 0){
			break;
		}
		
		cout << part(0, 0, 0) << endl;
		
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>

using namespace std;

int N, S, ans;

void rec(int base, int x, int used) {
    if(x == S && used == N) {
        ans += 1;
        return;
    }
    if(x > S) return;
    for(int i = base; i <= 9; i++) {
        rec(i + 1, x + i, used + 1);
    }
}

int main(void) {
    while(1) {
        scanf("%d%d", &N, &S);
        if(N == 0 && S == 0) break;
        ans = 0;
        rec(0, 0, 0);
        printf("%d\n", ans);
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
int n,s;
while(cin>>n>>s,n||s){
bool in[10]={0};
rep(i,n)in[i]=1;
sort(in,in+9);
int co=0;
do{
int sum=0;
rep(i,10)if(in[i])sum+=i;
if(sum==s)co++;
}while(next_permutation(in,in+10));
cout<<co<<endl;
}
}

C++: #include <iostream>
using namespace std;
int n,m;
int ans;
void dfs(int sum,int i,int n){
  if(n == 0 && sum == m){
    ans++;
    return;
  } 
  if(n == 0 || i == 10)return; 
  dfs(sum,i+1,n);
  dfs(sum+i,i+1,n-1);
}
int main(){
  while(cin >> n >> m,n){
    ans = 0;
    dfs(0,0,n);
    cout << ans << endl;
  }
}