Joseph's C language array Solution

Source: Internet
Author: User


1, 2 ,..., n of the n people sit at the Round Table clockwise. Each person holds a password (positive integer), starts reporting the number of s people, reports the number to the m people, and reports the number from the next person, until all members are listed

Below is the C language source program compiled using the array method! For your reference only. Please give me more valuable comments!

# Include <stdio. h>
Main ()
{
Int n, s, password;
Int a [100];
Int I, j, counter1 = 1, counter2 = 0;
Printf ("please input the value of n :");
Scanf ("% d", & n );
Printf ("please input the number of the biginer :");
Scanf ("% d", & s );
If (s> n)
{
Printf ("please reinput the number less than % d:", n );
Scanf ("% d", & s );
}
Printf ("please input the value of the password :");
Scanf ("% d", & password );

For (I = 0; I <n; I ++)
A [I] = I + 1;
J = s-1;
While (counter2! = N)
{
While (password = 1)
{
Printf ("% 4d", a [j]);
Counter2 ++;
If (counter2 = n)
Return;
If (j <n-1)
J ++;
Else
J = 0;
}
While (password! = 1 & counter1! = Password)
{
If (j <n-1)
J ++;
Else
J = 0;
While (a [j] = 0)
{
If (j <n-1)
J ++;
Else
J = 0;
}
Counter1 ++;
If (counter1 = password)
{
Printf ("% 4d", a [j]);
A [j] = 0;
If (j <n-1)
J ++;
Else
& Nb

Related Article

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.