Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int NUMBER_OF_WOMENS = 1000;
- int countNumbers = NUMBER_OF_WOMENS;
- int[] array = new int[NUMBER_OF_WOMENS];
- for (int i = 0; i < NUMBER_OF_WOMENS; i++)
- array[i] = i+1;
- while (countNumbers > 1)
- for (int i = 0; i < NUMBER_OF_WOMENS; i++)
- {
- int step = 1, index = (i + step >= NUMBER_OF_WOMENS) ? i + step - NUMBER_OF_WOMENS : index = i + step;
- if (array[i] == 0)
- continue;
- while (array[index] == 0) // check how match zeros after the number.
- index = (i + step >= NUMBER_OF_WOMENS) ? i + step++ - NUMBER_OF_WOMENS : index = i + step++;
- array[index] = 0;
- countNumbers--;
- }
- // print the number
- for (int i = 0; i < NUMBER_OF_WOMENS; i++)
- if (array[i] != 0)
- Console.WriteLine("The number of women is : " + array[i]);
Advertisement
Add Comment
Please, Sign In to add comment