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 <cstring>

using namespace std;

int n, s, *num, pattern;
void search(int th) {
  if (th == n) {
    int sum = 0;
    for (int i = 0; i < n; i++)
      sum += num[i];
    if (s == sum) {
      for (int j = 0; j+1 < n; j++)
        if (num[j] >= num[j+1])
          return;
      /*                                                                                                                                                                                                  
      for (int j = 0; j < n; j++)                                                                                                                                                                         
        cout << num[j];                                                                                                                                                                                   
      cout << endl;                                                                                                                                                                                       
      */
      pattern++;
    }
  } else {
    for (int i = 0; i < 10; i++) {
      num[th] = i;
      search(th + 1);
    }
  }
}

int main(int argc, char *argv[]) {
  vector<int> result;
  while (true) {
    cin >> n >> s;
    if (n == 0 && s == 0)
      break;
    num = new int[n];
    memset(num, 0, sizeof(int) * n);

    pattern = 0;
    search(0);
    result.push_back(pattern);
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 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<bits/stdc++.h>
using namespace std;
int serch(int i,int j,int n)
{
    if(i==10)return 0;
    else if(n==0&&j==0)return 1;
    else if(j<=0||n==0||j<i)return 0;
    return serch(i+1,j-i,n-1)+serch(i+1,j,n);
}
int main()
{
    int n,s,num;
    while(cin>>n>>s&&(n!=0&&s!=0)){
        num=serch(0,s,n);
        cout<<num<<endl;
    }
}

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

int n ;
int s ;
int ans ;
int sum ;
bool vis[12] ;

void init ( ) ;
void DFS ( int source , int k ) ;

int main ( )
{
	while ( scanf ( "%d %d" , &n , &s ) == 2 ) {
		if ( n == 0 || s == 0 ) break ;
		init ( ) ;
		DFS ( 0 , 0 ) ;
		printf ( "%d\n" , ans ) ;
	}
	return 0 ;
}

void init ( )
{
	memset ( vis , false , sizeof ( vis ) ) ;
	ans = 0 ;
	sum = 0 ;
}

void DFS ( int source , int k )
{
	if ( source == n ) {
		if ( sum == s ) {
			ans++ ;
		}
		return ;
	}
	for ( int i = k ; i <= 9 ; i++ ) {
		if ( vis[i] == false ) {
			vis[i] = true ;
			sum += i ;
			DFS ( source + 1 , i ) ;
			vis[i] = false ;
			sum -= i ;
		}
	}
}

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

typedef long long ll;

// dp[k][s][prev] := 最後に使った数がprev-1でk個使って和がsになる組合せ
ll dp[10][1010][110] = {0};

int main(){
	for(int i = 0; i <= 110; i++) dp[1][i][i+1] = 1;
	
	for(int k = 1; k < 9; k++){
		for(int i = 0; i <= 1010; i++){
			for(int prev = 0; prev <= 110; prev++){
				if( dp[k][i][prev] ){
					for(int j = prev; j <= 110; j++){
						if( k+1 < 10 && i + j < 1010 && j + 1 < 110 ){
							dp[k+1][i+j][j+1] += dp[k][i][prev];
						}
					}
				}
			}
		}
	}
	int n, s;
	while( cin >> n >> s, n || s ){
		ll res = 0;
		for(int i = 0; i <= 110; i++){
			res += dp[n][s][i];
		}
		cout << res << endl;
	}
}

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

int c,g;

int hcount(int n,int sum,int bf){
	if(n==0){
		if(sum==g){
			c++;
		}
	}
	else{
		for(int i=bf+1;i<10;i++){
			hcount(n-1,sum+i,i);
		}
	}
	return 0;
}

int main(){
	int n;
	while( scanf("%d %d",&n,&g)!=EOF){
		if(n==0&&g==0)break;
		c=0;
		hcount(n,0,-1);
		printf("%d\n",c);
	}
			
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;

int ans;
int a, b;

void solve(int i ,int _b, int sum){
	if (sum == a && _b == 0){
		ans++;
		return;
	}
	if (_b==0 || i == 10)return;
	solve(i + 1, _b, sum);
	solve(i + 1, _b - 1, sum + i);
}

int main(){
	while (cin >> b >> a, a&&b){
		ans = 0;
		solve(0, b, 0);
		cout << ans << endl;
		
	}
	return 0;
}

C++: #include<stdio.h>
void func(int,int);
int n,m,cnt,sum;
int main(void)
{
	while(1){
		int i,j;
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		cnt=0; sum=0;
		func(0,0);
		printf("%d\n",cnt);
	}
	return 0;
}
void func(int nn,int x)
{
	int i;
	if(nn==n&&sum==m) cnt++;
	else{
		for(i=x;i<10;i++){
			sum+=i; func(nn+1,i+1);
			sum-=i;
		}
	}	
}

C++: // AOJ.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"
#include "stdio.h"
#include <vector>
#include <iostream>

using namespace std;

class Puzzle
{
public:
	vector<int> used;


	void input()
	{

	}

	void play()
	{
		int n;
		int s;
		int ans = 0;
		used = vector<int>(10, 0);

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

			ans = try_sum(n, s, 0);
			printf("%d\n",ans);
		}
	}

	int try_sum(int n, int s, int min)
	{
		if (n == 0 && s == 0) return 1;
		if (n == 0 || s <= 0) return 0;
		int ans = 0;

		for (int ni = min; ni < 10; ni++) {
			if (used[ni] == 0 ) {
				used[ni] = 1;
				ans += try_sum(n - 1, s - ni, ni + 1);
				used[ni] = 0;
			}
		}

		return ans;
	}

};


int main()
{
	Puzzle puz;

	puz.input();
	puz.play();

    return 0;
}

C++: #include<cstdio>
int ans;
int n,s;
bool tryfunc(int now,int dep,int rest){
    if(rest==now && dep==0) ans++;
    else if(rest>now && dep>0){
        for(int i=now+1;i<=(rest-now>s ? s:rest-now);i++){
            tryfunc(i,dep-1,(rest-now>s ? s:rest-now));
        }
    }
}
int main(){
    for(;;){
        ans=0;
        scanf("%d%d",&n,&s);
        if(n==0 && s==0) break;
        for(int i=0;i<10;i++){
            tryfunc(i,n-1,s);
        }
        printf("%d\n",ans);
    }
}