Help With Algorithm Egyptian Numbers

This is a discussion on Help With Algorithm Egyptian Numbers within the C++ Programming forums, part of the General Programming Boards category; So, i'm trying to figure out the algorithm for detecting egyptian numbers in the array and adding them properly. I ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    12

    Help With Algorithm Egyptian Numbers

    So, i'm trying to figure out the algorithm for detecting egyptian numbers in the array and adding them properly.

    I can't seem to understand how to go from here. I can't think of how to add the numbers together because when the user enters " IINNNNNNNN " and wants to subtract " I ", i don't know how i would code that >.>
    Code:
    void eMath::AddEgyptianNumbers()
    {
    	static char eNumber1[40];
    	static char eNumber2[40];
    
    	struct EgyptianDigit
    	{
    		char *EgyptianSymbol;
    		int EgyptianValue;
    	};
    
    static const EgyptianDigit EgyptianDigitValue[]=
    {
    	{"Y",1000000},
    	{"O",100000},
    	{"/",10000},	  
            {"L",1000},
            {"9",100},
    	{"N",10},
            {"I",1},
    };
    	
    }

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Sorry, but
    Code:
    	static char eNumber1[40];
    	static char eNumber2[40];
    Why static?

    Aside from that, translate each component to an integer value, then subtract the integer values from each other and convert back to Egyptian numbers.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    12
    Thanks! It'll just take some time to get it done but i get it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 06:20 AM
  2. Adding Line numbers in Word
    By Mister C in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 06-24-2004, 09:45 PM
  3. the definition of a mathematical "average" or "mean"
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 12-03-2002, 11:15 AM
  4. Line Numbers in VI and/or Visual C++ :: C++
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 02-10-2002, 10:54 PM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 06:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21