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 <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int ans;
int n,s;

void solve(int num, int sum, int select) {
	if(select == n && sum == s) {
		ans++;
		return;
	}
	if(select == n) return;
	for(int i = num; i <= 9; i++) {
		solve(i+1,sum+i,select+1);
	}
}

int main() {
	for(; cin>>n>>s && n && s;) {
		ans = 0;
		solve(0,0,0);
#if 0
		for(int i = 0; i <= 9; i++) {
			for(int j = i + 1; j <= 9; j++) {
				if(i + j == s) ans++;
			}
		}
#endif
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream> 

int main(){
	int a,b;	
	while(std::cin>>a>>b&&a!=0&&b!=10){
		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 B[10] = {};
void partialSum(int& c, int i, int k, int n, int s, int* A, int sum)
{
	if (i > 9 || k > n || sum > s)
		return;
	if (k == n && s == sum){
		++c;
		return;
	}
	partialSum(c, i + 1, k, n, s, A, sum);
	for (int i = 0; i < k; ++i) B[i] = A[i];
	B[k] = i;
	partialSum(c, i + 1, k + 1, n, s, B, sum + i);
}
int main()
{
	int n, s, c, i, k, sum;
	int A[10] = {};
	while (cin >> n >> s){
		if (0 == s && 0 == n) break;
		c = i = k = sum = 0;
		partialSum(c, i, k, n, s, A, sum);
		cout << c << "\n";
	}
	return 0;
}