ZJU1088

// 1088.cpp : Defines the entry point for the console application. /**************************************/ /**************joseph环问题************/ /**************************************/  #include "stdafx.h" #include "iostream" using namespace std; int m,n; int search(int j) { int i; int from=0; for(i=2;i<n;++i) { 	from=(from+m)%i; } if(from==0) return 1; else return 0;  } int main(int argc, char* argv[]) {    m=1; cout<<"input your number:"; while((cin>>n)&&(n>0)) {  while(!search(n)) {++m;} cout<<"is :"<<m<<endl<<"input your number:"; m=1;  } 	printf("Hello World!\n"); 	return 0; }

你可能感兴趣的:(算法)