Array Implementation of Joseph's Problem

Source: Internet
Author: User


Recently, I have seen many programs with Joseph problems in C language, including C and C ++. the implementation methods are linked lists, and basically no arrays are used. I have previously used pascal to write an array and a linked list to solve this problem separately. Now I will rewrite the implementation process of the array method in C language for reference. If there are any errors or omissions, please correct.

/* ===================================================== =================== */
/* Program name: arrayList. c */
/* Program objective: to implement Joseph's problem using arrays */
/* Program Author: aibd (computer 021 )*/
/* ===================================================== =================== */
# Include <stdio. h>
# Define size 100/* Maximum number of input users */

Void main ()
{
Int person [size];
Int I, j;/* cyclically corrected variable */
Int arrayLen;/* array length */
Int start, overNum;/* start position and cross position */
Int deleNum;/* subscript in the array where the columns are located */
Int name, total;/* enter the person information and total number of people */
Printf ("Enter the total number of round tables :");
Scanf ("% d", & arrayLen); printf ("n ");
If (arrayLen> size) | (arrayLen <0 ))
{
Printf ("out of range, please enter again :");
Scanf ("% d", & arrayLen); printf ("n ");
};
Printf ("enter individual information (integer): n ");
For (I = 0; I <arrayLen; I ++)
{
Scanf ("% d", & name );
Person [I] = name;
}
Printf ("the order of your input data is: n ");
For (I = 0;

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.