ex.
send+more=money
how can i write program to solve what value of a,n,t,c,n.
i have code but it not fast and clever to process
#include <stdio.h>
void main()
{
FILE *file;
int s=0,e=0,n=0,d=0,m=0,o=0,r=0,y=0,z=0,c=0;
file = fopen("Cryptarithm.txt", "w");
for(s=0;s<=9;s++)
{
for(e=0;e<=9;e++)
{
for(n=0;n<=9;n++)
{
for(d=0;d<=9;d++)
{
for(m=0;m<=9;m++)
{
for(o=0;o<=9;o++)
{
for(r=0;r<=9;r++)
{
for(y=0;y<=9;y++)
{
if (((((s*1000)+(e*100)+(n*10)+(d*1))+(m*1000)+(o*100)+(r*10)+(e*1)))==((m*10000)+(o*1000)+(n*100)+(e*10)+(y*1)))
{
c=c++;
fprintf(file,"No. %d \t",c);
fprintf(file,"send = %d%d%d%d \t",s,e,n,d );
fprintf(file,"more = %d%d%d%d \t",m,o,r,e );
fprintf(file,"money = %d%d%d%d%d\t",m,o,n,e,y );
fprintf(file,"\n");
printf("No. %d \t",c);
printf("send = %d%d%d%d \t",s,e,n,d );
printf("more = %d%d%d%d \t",m,o,r,e );
printf("money = %d%d%d%d%d\t",m,o,n,e,y );
printf("\n");
}
}
}
}
}
}
}
}
}
}
This post has been edited by maxzzxam: 06 December 2008 - 04:42 AM

Start a new topic
Add Reply




MultiQuote

| 


