View Code of Problem 80

#include<stdlib.h>
#include<stdio.h>

int main(){
	int n;
	while((scanf("%d",&n)!=EOF)&& n!=0){
		int num[10000]={0};
		int count=0;
		int del=0;
		for(int i=1; i<=n ;i++){
			if(num[i]==0){
				count++;
				if(count%3==0){
					num[i]=1;
					del++;
				}
				if(del==(n-1))
					break;
			}
			if(i==n)
				i=0;
		}

		for(int i=1; i<=n ;i++){
			if(num[i]==0){
				printf("%d\n",i);
				break;
			}
		}
	}
	

	return 0;
}

Double click to view unformatted code.


Back to problem 80