Language: C++

#include <iostream>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <cmath>

using namespace std;
#define INF 1e9
int Eq[27], Zero[27];
vector<int> TC, hash, zr;

int check(){
	int sum=0;
	int i;
	for(i=0;i<int(hash.size());i++){
		sum += hash[i] * TC[i];
	}
	return sum ? 0 : 1;
}

int solve(){
	int i, j, sum = 0;
	if(hash.size() == TC.size()) return check();
	for(i=0;i<=9;i++){
		if(!i && zr[TC.size()]) continue;
		for(j=0;j<int(TC.size());j++) if(i==TC[j]) break;
		if(j<int(TC.size())) continue;
		TC.push_back(i);
		sum += solve();
		TC.pop_back();
	}
	return sum;
}

main(){
	int n, i;
	char buf[10];
	while(cin>>n,n){
		for(i=0;i<26;i++){
			Eq[i] = INF;
			Zero[i] = 0;
		}
		hash.clear();
		zr.clear();
		TC.clear();
		while(n--){
			cin>>buf;
			if(buf[1]) Zero[buf[0]-'A'] = 1;
			strrev(buf);
			for(i=0;buf[i];i++){
				if(Eq[buf[i]-'A'] == INF) Eq[buf[i]-'A'] = pow(10, i) * (n?1:-1);
				else Eq[buf[i]-'A'] += pow(10, i) * (n?1:-1);
			}
		}
		for(i=0;i<26;i++)if(Eq[i] != INF) hash.push_back(Eq[i]),zr.push_back(Zero[i]);
		cout << solve() << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int check()':
a.cc:15:19: error: expected primary-expression before 'int'
   15 |         for(i=0;i<int(hash.size());i++){
      |                   ^~~
a.cc:15:19: error: expected ';' before 'int'
   15 |         for(i=0;i<int(hash.size());i++){
      |                   ^~~
      |                   ;
a.cc:15:19: error: expected primary-expression before 'int'
   15 |         for(i=0;i<int(hash.size());i++){
      |                   ^~~
a.cc:15:19: error: expected ')' before 'int'
   15 |         for(i=0;i<int(hash.size());i++){
      |            ~      ^~~
      |                   )
a.cc:15:19: error: expected primary-expression before 'int'
   15 |         for(i=0;i<int(hash.size());i++){
      |                   ^~~
a.cc:15:39: error: expected ';' before ')' token
   15 |         for(i=0;i<int(hash.size());i++){
      |                                       ^
      |                                       ;
a.cc: In function 'int solve()':
a.cc:23:12: error: reference to 'hash' is ambiguous
   23 |         if(hash.size() == TC.size()) return check();
      |            ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:10:17: note:                 'std::vector<int> hash'
   10 | vector<int> TC, hash, zr;
      |                 ^~~~
a.cc: At global scope:
a.cc:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:43:17: error: reference to 'hash' is ambiguous
   43 |                 hash.clear();
      |                 ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:10:17: note:                 'std::vector<int> hash'
   10 | vector<int> TC, hash, zr;
      |                 ^~~~
a.cc:49:25: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   49 |                         strrev(buf);
      |                         ^~~~~~
      |                         strsep
a.cc:55:51: error: reference to 'hash' is ambiguous
   55 |                 for(i=0;i<26;i++)if(Eq[i] != INF) hash.push_back(Eq[i]),zr.push_back(Zero[i]);
      |                                                   ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:10:17: note:                 'std::vector<int> hash'
   10 | vector<int> TC, hash, zr;
      |                 ^~~~