View Code of Problem 80

#include<stdio.h>

int main(void)
{
	int i,n,count=0,a[100],temp;
	while(scanf("%d",&n)!=0)
	{
		for(i=0;i<n;i++)
		{
			a[i]=1;
		}
		temp=n;
		i=0;
		while(n>1)
		{
			if(a[i]!=0)
			{
				count++;
			}
			if(count==3)
			{
				a[i]=0;
				count=0;
				n--;
			}
			i++;
			if(i==temp)
			{
				i=0;
			}
		}
		for(i=0;i<temp;i++)
		{
			if(a[i]!=0)
			{
				printf("%d\n",i+1);
			}
		}
	}
	
}

Double click to view unformatted code.


Back to problem 80