View Code of Problem 80

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

int main()
{
	int a[50], i, n, count, flag = 0;
	scanf("%d", &n);
	count = n;
	for (i = 1; i <= n; i++)
		a[i] = 1;
	for (i = 1; ;i++)
    {
		if (i == n+1)
			i = 1;
		if (a[i] != 0)	
            flag++;
		else	
            continue;
		if (flag % 3 == 0)
        {
			a[i] = 0;
			count--;
		}
		if (count == 1)
			break;
	}
	for (i = 1; i <= n; i++)
	{
        if (a[i] != 0)
			printf("%d", i);
    }	
	return 0;
} 

Double click to view unformatted code.


Back to problem 80