21 printf(
"\nTMath::Permute simple test\n");
22 printf(
"==========================\n");
27 for(i=0; i<4; i++)
a[i]=i;
30 for(
Int_t i=0;i<4;printf(
"%c",
static_cast<char>(aa+
a[i++])));
34 printf(
"Found %d permutations = 4!\n",icount);
40 printf(
"\nTMath::Permute simple test with repetition\n");
41 printf(
"==========================================\n");
46 for(i=0; i<6; i++)
a[i]=(i+2)/2;
49 for(
Int_t i=0;i<5;printf(
"%c",
static_cast<char>(aa+
a[i++])));
53 printf(
"Found %d permutations = 5!/(2! 2!)\n",icount);
65 Int_t nine, three, neuf, trois;
67 printf(
"\nTMath::Permute fancy test\n");
68 printf(
"=========================\n");
69 printf(
"This is a program to calculate the solution to the following problem\n");
70 printf(
"Find the equivalence between letters and numbers so that\n\n");
71 printf(
" NINE*THREE = NEUF*TROIS\n\n");
72 for(
Int_t ii=0; ii<10; ii++)
a[ii]=ii;
74 nine=((
n*10+i)*10+
n)*10+
e;
75 neuf=((
n*10+
e)*10+u)*10+
f;
76 three=(((t*10+
h)*10+
r)*10+
e)*10+
e;
77 trois=(((t*10+
r)*10+o)*10+i)*10+s;
78 if(nine*three==neuf*trois) {
79 printf(
"Solution found!\n\n");
80 printf(
"T=%d N=%d E=%d S=%d F=%d H=%d R=%d I=%d O=%d U=%d\n",t,
n,
e,s,
f,
h,
r,i,o,u);
81 printf(
"NINE=%d THREE=%d NEUF=%d TROIS=%d\n",nine,three,neuf,trois);
82 printf(
"NINE*THREE = NEUF*TROIS = %d\n",neuf*trois);
86 printf(
"No solutions found -- something is wrong here!\n");
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Bool_t Permute(Int_t n, Int_t *a)
Simple recursive algorithm to find the permutations of n natural numbers, not necessarily all distinc...