473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Question about chained sequence

2
Hi guys, how are you hope you are ok. First of all I'd like to thank you for the fantastic forum. I have a problem with c++. 10 days ago, I tried to solve a program and i didn’t reach to any thing. Also I asked a lot of people and forums but no body could solve it.:(
Please I'm very depressed, I wish you to help me.
Thank you

Dec 8 '06 #1
2 992
DeMan
1,806 1GB
You will probably find that people in most forums (including this one) don't like to complete assignments without seeing some sign that they have been attempted.......

the basic logic would be (in some form of non-standard pseudocode)......

Expand|Select|Wrap|Line Numbers
  1. found=false;
  2. if this_number.number_of_digits=last_number.number_of_digits
  3. while(!found && this_number.hasMoreDigits)
  4. {
  5.   if (abs(this_number-last_number)<10)
  6.   {
  7.     found =true;
  8.   }
  9. }
  10. return found
  11.  
Dec 8 '06 #2
DeMan
1,806 1GB
That's not actually (even close to) right (sorry) I don't know what I was thinking last night...

The last digit is the same if the two numbers are equal mod 10.
The last two digits are the same if the numbers are equal mod100
The last 3 digits are equal if the numbers are equal mod1000
.
.
The last n digits are equal if the numbers are equal mod 10^(n-1)
I think is what i meant, but that is still not entirely right

I think that it should've been
Expand|Select|Wrap|Line Numbers
  1. found=false;
  2. if( this_number.number_of_digits=last_number.number_of  _digits)
  3. {
  4. n=10;
  5.   while(!found && n<thisnumber)
  6.   {
  7. int difference =this_number-last_number;
  8.     if ((abs(difference)mod n ==0)&&fifference/n <10)
  9.     {
  10.       found =true;
  11.     }
  12.   n=n*10;
  13.   }
  14.   return found;
  15. }
  16.  
Obviously you also need to check that this is true for the last number and first number
Dec 9 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: RK | last post by:
I was reading the Concepts manual and was puzzled by this sentence. Can anyone elaborate on this: <snip> Tables are the basic unit of data storage in an Oracle database. Database tables hold all...
12
by: Mark | last post by:
Apologies for the lengthy posting.... In a previous posting:...
7
by: gregincolumbus | last post by:
Hello I have used chained selects to populate two selects. When the user chooses from first select, he is presented with the populated data for the 2nd select. The result is a list of numbers. ...
0
by: Rowland Smith | last post by:
Is anyone aware of a module or recipe for defining a composite/chained exception superclass? I've seen the PEP on chained exceptions wrt Python-3K, but I'm looking for something that is 2.5...
2
by: RK | last post by:
I was reading the Concepts manual and was puzzled by this sentence. Can anyone elaborate on this: <snipTables are the basic unit of data storage in an Oracle database. Database tables hold all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.