C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C++ Expert!

Join 306,807 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,668 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

maxzzxam

5 Dec, 2008 - 07:36 PM
Post #1

New D.I.C Head
*

Joined: 5 Dec, 2008
Posts: 1

- 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

CODE

#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: 6 Dec, 2008 - 04:42 AM

User is offlineProfile CardPM
+Quote Post


OliveOyl3471

RE: How Can I Solve Cryptarithm By C

5 Dec, 2008 - 10:21 PM
Post #2

Quick and Dirty
Group Icon

Joined: 11 Jul, 2007
Posts: 5,646



Thanked: 107 times
Dream Kudos: 775
Expert In: Basketball

My Contributions
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: 5 Dec, 2008 - 10:23 PM
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 11/20/09 09:48PM

Live C++ Help!

Be Social

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

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month