http://en.wikipedia.org/wiki/Josephus_problem ユーザーはサークル内の人数を選択できます。ユーザーは、各人の値を選択できます。ユーザーは、人の死亡のカウント数を選択できます。元。ユーザーが 5 人を選ぶと、5 人に 1 人が死亡します。
私は次のようなことを考えていました - ユーザーは人数を選択します ex- 50 PeopleArray は PeopleArray[50] になります
ユーザーは PeopleArray[50] の要素の値を選択します。50 個の要素に対して 50 個の値を入力する必要があります。
Death User は 3 を選ぶので、3 人に 1 人が死ぬので、どうすればその数字を配列から消去できますか。
問題 ^-配列で上記を行う方法がわからない
int main(){
int people = 5;
int peopleArray[5];
int peopleValue = 1;
int death;
cout << "Enter the amount of people: ";
cin >> people;
peopleArray[people];
for(int x = 1;x<=people;x++){
cout << "Enter the value of person #" << x << ":";
cin>> peopleValue;
peopleArray[peopleValue]; //Suppose to put the value into the array
}
}