int main()
{
	int M,N;	
	
	clrscr();
	cout<<"****************************************";	
	cout<<"\n\n   IMPLEMENTATION OF ELIMINATION GAME\n\n";
	cout<<"****************************************\n";
	while(M != 0)
	{
		cout<<"\n Enter number of players.(Maximum"<<MAX<<", Enter 0 to exit): ";
		cin>>M;
		if(M == 0)
		{
			cout<<"\n Exiting...";
			break;
		}
		if(M < 2 || M > MAX)
		{
			cout<<"\n Invalid Input. Try Again.\n";
		}	
		else
		{
			cout<<"\n Enter value for elimination.(Must be less than "<<M<<"): ";	// N must be less than M
			cin>>N;
			if(N>=M)
				cout<<"\n Invalid Data. Try Again.\n";
			else
				find_winner(M,N);
		}
	}
	
	return 1;
}
コード例 #2
0
int main(){
	int *a;
	int N,i,k;
	
	printf("Enter the size of array :");
	scanf("%d",&N);
	
	a = (int*)calloc(N,sizeof(int));
	
	for(i = 0 ; i < N ; i++)
		scanf("%d",&a[i]);
	
	printf("Enter value of k : ");
	scanf("%d",&k);
	
	find_winner(a,N,k);
	
}