![]() |
|
#1
|
|||
|
|||
Repeated digits in a number sequencethe problem is:
I want to know if there is any way to find repeated digits in a number sequence. for example : 12341 there are two "1's" and in 11 we can find two "1's" also. Is there some mathematical reason between them valid for any number sequence? I cant use array's or vector's of any kind and I also can't use String's or Integer. Only primitive tipes like int and char . I think this is only a maths problem. Can any one help me?! |
|
#2
|
|||
|
|||
Re: Repeated digits in a number sequenceThe only way I can see this working with these restraints is to do a loop modding by 10 and then subtracting that remainder, and then dividing by tens. Then check each char to see if any two are equal. So like the number 12341 would % 10 to get 1, store that to a char. Then take 12341-1 =12340 and then divide by ten. This will give you 1234. Then keep doing the same thing over again. At the end, make another loop starting at the first char and searching for an equivalent value. Then search the second char.
Again this can be done but it is so ineffiecient and long. Making the int into a string and then doing a charAt(i) for loop would be a lot better. |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Help with my Cards Program (C++) | krisopotamus | C++ Forum | 2 | 06-Oct-2005 17:48 |
| Anyone can write a program code for this??? | chriskan76 | C Programming Language | 1 | 19-Oct-2004 21:25 |
| looking for a way to identify a repetitive sequence of digits in an array or string | sho | C++ Forum | 8 | 15-Jun-2004 00:59 |
| Breaking the number into two digits | amir_b | C Programming Language | 3 | 16-Feb-2004 13:28 |
| How to find the last 6 digits of a 8 digit number? | rjd72285 | C++ Forum | 3 | 28-Oct-2003 09:21 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The