Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求助: 我的程序是什么问题呢?

Posted by Be_the_top at 2009-03-04 10:47:00 on Problem 1012
#include <iostream>
using namespace std;

bool kill(bool *pp,int i, int step)
{
    int w = 1, j, jj = -1;
    while(w <= i/2){
        w++;
        for(j = 1;j <= step;j++){   
            jj++;
            if(j == step){
                if(jj > i-1)
                    jj = jj%i;
                if(*(pp+jj) == false)
                j = j - 1;
                *(pp+jj) = false;
            }
        }
    }
   for(j = 0;j < i/2;j++){
        if(*(pp+j) == false)
        return false;
        if(j = i/2 -1)
        return true;
        }
}

int main()
{
    int n, i; 
    while(scanf("%d",&n) != 0){
        int j = 0;
        bool pp[26] = {1};
        i = 2*n;
        while(1){
            j++;
            if(kill(pp, i, j))
            break; 
        }
       printf("%d",j);
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator