Solved

Posted on 2000-01-18
Medium Priority
854 Views
I have a program and can't seem to figure out any decent way to approach the solution for it. It requires that I must use pointers and linked lists to solve the problem.  The program is as follows:

Write a program that reads a positive integer n input at a terminal and does the following:
1.  Prints the table of Farey fractions up to order n
2.  Prints the reversed table, i.e last row first.

For example, if n = 3, then the output looks somewhat like this:
1        0/1, 1/1

2        0/1, 1/2, 1/1

3        0/1, 1/3, 1/2, 2/3, 1/1
---------------------------------
3        0/1, 1/3, 1/2, 2/3, 1/1

2        0/1, 1/2, 1/1

1        0/1, 1/1

Ideal
0
Question by:Idealzx
• 4
• 2

LVL 22

Expert Comment

ID: 2365252
We cannot provide answers to school assignments.  That is grounds for removal from this site.  (for both you and the experts involved.)  We can provide only limitied help in accademic assignments.    We can answer specific (direct) questions, like you might ask your teacher.  We can review your work and post suggestions, again, like your teacher might do.

Do you have specific questions?
Do you have any work on this (incomplete even) that we can review?
0

LVL 6

Expert Comment

ID: 2367132
Couldn't have phrased it better myself (and I've tried often enough).  Request permission to cut for future pasting to other language forums which you might not patrol ?
0

LVL 22

Expert Comment

ID: 2367526
0

LVL 6

Expert Comment

ID: 2370585
then who am I to think that I am somehow bnetter than others?
0

LVL 22

Expert Comment

ID: 2370630
Well its nice to be asked anyways.
0

Accepted Solution

Arvindtn earned 100 total points
ID: 2373421
I don't have enough time to give you the code may be i could give you the logic.

Have a Double Link List which would contain the numbers 1 ... n, For each value of N, have another single link list which contain the value for that particular node value ( Value of N ).

Prototype would be

Struct Data
{
int Number;
//would contain the number 1...N
}

Struct Fraction
{
float Fract;
// would contain the value of 0/1, etc
}

Struct Vertical
{
Fraction FractValue;
Vertical *NextNode;
}

Struct Horizontal
{
Horizontal *PreviousNode;
Data Num;
Horizontal *NextNode;
Vertical *StartNode;
}

if you have any problem in understanding feel free to message me
0

LVL 22

Expert Comment

ID: 2374064
Arvindtn, you did read the question history, right?  Personally, I don't think what you posted was to much, but you need to be careful.  Provide help, not the answer.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
###### Suggested Courses
Course of the Month5 days, 12 hours left to enroll