School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,030 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 4,096 people online right now. Registration is fast and FREE... Join Now!



how can i solve cryptarithm by c

how can i solve cryptarithm by c use c program to solve cryptarithm Rate Topic: -----

#1 maxzzxam  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 1
  • Joined: 05-December 08


Dream Kudos: 0

Posted 05 December 2008 - 07:36 PM

- how can i write program to solve cryptarithm

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

Was This Post Helpful? 0
  • +
  • -


#2 OliveOyl3471  Icon User is online

  • Everybody's crazy but me!
  • Icon
  • Group: Moderators
  • Posts: 6,515
  • Joined: 11-July 07


Dream Kudos: 775

Expert In: Basketball

Posted 05 December 2008 - 10:21 PM

Well, first you need to write some code.

Dream.in.code's policy is not to provide answers unless the asker shows a good faith effort and provides their code.

This post has been edited by OliveOyl3471: 05 December 2008 - 10:23 PM

Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month