Examples of the C language - Joseph living and the dead game

30 people in the same boat, overloaded, take 15 people off the boat.

So people lined up, line up the position that is their number.

Report number, starting from 1, 9 to number of people disembark.

This cycle, until the remaining 15 people on board so far, and asked what number of people have disembarked it?

#include<stdio.h>
 
int c = 0;
int i = 1;
int j = 0;
int a[30] = { 0 };
int b[30] = { 0 };
 
int main()
{
    while (i<=31)
    {
        if (i == 31)
        {
            i = 1;
        }
        else if (c == 15)
        {
            break;
        }
        else
        {
            if (b[i] != 0)
            {
                i++;
                continue;
            }
            else
            {
                j++;
                if (j != 9)
                {
                    i++;
                    continue;
                }
                else
                {
                    b[i] = 1;
                    a[i] =J; 
                    J = 0 ; 
                    the printf ( " % d of No. disembark \ n- " , I); 
                    I ++ ; 
                    C ++ ; 
                } 
            } 
        } 
    } 
}

 

Guess you like

Origin www.cnblogs.com/HGNET/p/11763598.html