View Code of Problem 80

#include <stdio.h>
#include <string.h>
#include <math.h>
int main(){
	int n;
	int count;
	int out;
	while(scanf("%d",&n)!=EOF&&n!=0){
		count=0;
		out=0;
		int i=0;
		int a[1000]={0};
		while(out!=n-1){
			if(a[i]==0){
				count++;
				count=count%3;
				if(count==0){
					a[i]=1;
					out++;
				}
			}
			i++;
			if(i==n)
				i=0;
		}
		 for(i=0;i<n;i++){
		 	if(a[i]==0)
		 	printf("%d\n",i+1);
		 }
		
	}
		
}

Double click to view unformatted code.


Back to problem 80