Hunan City UNIVERSITY
Course design of data structure
Instruction manual
Design topic : Joseph number
Major : computer Science and technology
Student name :
class number :
Group members :
Instructor:
July 3, 2015
"Data structure" Course Design Manual
1306402 03 Liu Dehao
First, design time
June 29, 2015-----July 03, 2015
Second, the design site
Laboratory building of Hunan City College 407 computer room
Third, the purpose of design
1. Consolidate and deepen the understanding of the knowledge structure course, understand and master the design method of data structure and algorithm;
2. Master the basic methods and skills of problem analysis, System design, program coding and testing of software development process;
3. Improve the comprehensive use of the theoretical knowledge and methods, independent analysis and problem-solving ability;
4. The training uses the system viewpoint and the software development general standard to carry on the software development, trains the software worker to have the scientific work method and the style;
5. Develop the ability to access information and to think independently of problems.
Four Design team members
Five Teacher Guidance
Six Design topics
Numbered ".", ..., N. n individuals sit around in a clockwise direction, each holding a password (positive integer). At the beginning of any given a positive integer as the top value m, starting from the first person to start in the clockwise direction from 1 to begin the sequence, check m stop Count, reported m of the person out, will his password as a new m value, from his clockwise direction of the next person began to re-count from 1, so down until all of them out.
Seven Basic ideas and solutions to key issues
This problem with a one-way cycle linked list simulation of the process, according to the number of passwords in order to select each number, according to the sequence of the number of print out, mainly in the establishment of a one-way cycle chain list, and in accordance with the number of password to delete each node, the first line of input people number n, the second line of the number
Eight Algorithm and flowchart
Nine Problems during commissioning and corresponding solutions
Start debugging when there are many errors, more errors in the grammar above, mainly due to the syntax unfamiliar with some of the comparison of the basis of the error, after debugging phenomenon came out, from which can be seen in the pointer this piece there are many shortcomings, more familiar with, as to the algorithm is not too difficult, As long as the establishment of a one-way cycle linked list by the number of passwords to select each number.
Ten Experience in curriculum design
This course design is quite touching, for a topic need to first put all the design options are listed, and then choose a most suitable solution to do, this will be much easier, less go a lot of detours, if in the design debugging there is a problem, first of all to see is not a grammar problem, in their own thinking on the paper on the list again, See if there's a problem. Often the result of debugging is not come out, lies in some places did not think.
Xi. SOURCE program
struct cirnode/* defines the type of each node */
{
int data;/* The password that everyone has */
int num;/* The bit order of everyone in the circle */
struct Cirnode *next;
};
int a[30]; /* Number required ≤30 */
struct Cirnode *createlist (int n)/* Generates a one-way cyclic list of n nodes */
{
struct Cirnode *l,*p,*q;
int i;
int j=1;
l=q= (struct cirnode*) malloc (sizeof (struct cirnode));
/* Create a one-way loop list without a lead node */
if (!Q)
return ERROR;
printf ("Shu ru mei ge ren de mi ma:\n");
q->num=j;
printf ("%d.data=", j);
scanf ("%d", &q->data);
j + +;
q->next=l;
for (I=1; i<n; i++)
{
p= (struct cirnode*) malloc (sizeof (struct cirnode));
printf ("Shu ru mei ge ren de mi ma:\n");
p->num=j;
printf ("%d.data=", j);
scanf ("%d", &p->data);
j + +;
q->next=p;
p->next=l;
q=q->next;
}/*for*/
return (L);
}/*create*/struct cirnode *deletelist (struct cirnode *l,int m,int N)//* * For people who report m/
{
int i,j=0;
int k=n;
struct Cirnode *p,*q,*pre;
Pre=p=l;
Do
{
I=1;
while (i<m-1)
{
p=p->next; /*else*/
i++;
}
if (m==1)
{
while (pre->next!=p) pre=pre->next;
m=p->data;/* get a new password */
a[j]=p->num;/* get the number of people out of the row * *
Q=p;
pre->next=p->next;
p=p->next;
Free (q);
l=pre=p;/* let the new newspaper 1 people as the head of the node * *
k--;
j + +;
}/*if */else
{
q=p->next;
m=q->data;
a[j]=q->num;
p->next=q->next;
p=q->next;
Free (q);
L=pre=p;
k--;
j + +;
}
}
while (k>1);
a[j]=p->num;/* the number of the last person to be dequeue
printf ("Xian zai suo you ren chu lie.\n");
return (L);
}/*deletelist*/int Main ()
{
struct Cirnode *l;
int i,n,m;
printf ("======this is a Joseph problem======\n");
printf ("Qing shu ru ren shu,n=");
scanf ("%d", &n);
if (n>30| | N<1)
{
printf ("error! Please input again,n= ");
scanf ("%d", &n);
}/*if*/l=createlist (n);
printf ("Please input the first code,m=");
scanf ("%d", &m);
if (m<1)
{
printf ("error! Please input again,m= ");
scanf ("%d", &m);
}/*if */deletelist (l,m,n);
printf ("Chu Dui ren de shun xu31:\n");
for (i=0; i<n; i++) printf ("%d", a[i]);
printf ("\ n");
Reference documents
[1] Min, 聯繫 Editor, "Data structure" (C language Edition) Tsinghua University Press 2002
[2] Min, 聯繫 "Data structure problem" (C language Edition) Tsinghua University Press
[3] Rectification "Object-oriented Programming" (C + +) Tsinghua University Press
Course design of data structure