GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 31-Oct-2005, 06:17
pedro_21 pedro_21 is offline
New Member
 
Join Date: Oct 2005
Posts: 1
pedro_21 is on a distinguished road
Exclamation

Repeated digits in a number sequence


the 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  
Old 01-Nov-2005, 16:03
mattd1688 mattd1688 is offline
New Member
 
Join Date: Oct 2005
Location: Mass
Posts: 3
mattd1688 is on a distinguished road

Re: Repeated digits in a number sequence


The 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 GIDBlogWriting a book by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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

All times are GMT -6. The time now is 10:29.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.