Need Help regarding With Josephus problem c++

Is there any Method to change a to z alphabets into Names(add by user and names more than ten or more :) is there any method to add easily names without consuming time because tomorrow is my project Exam and i need you to change code and give me better ideas to change code myself


PS : PLEASE DO NOT USE THIS CODE FOR SCHOOL PROJECT BECAUSE COPY IS NOT A SOLUTION TO PASS IN PROGRAMMING LEARNING IS POWER

example
Enter Number 1 : John
Enter Number 2 : Tony Stark
Enter Number 3 : Steve Job
John Killed Steve and Tony Killed John and Tony is the winner :)
yahoooo!!!!
----------------------------------------------------------------

[#include <iostream>
#include<cstdlib>
#include<string>



using namespace std;
void KillChar(char* temp, int index);

int main()
{

string name;
cout << "Enter Person 1 Name : ";
cin >> name;
string name2;
cout << "Enter Person 2 Name :";
cin >> name2;
{
cout << "length of first name = " << name.length() << endl;
cout << "length of 2 name = " << name2.length() << endl;
}
int NumberofPeople;
int skip;
int Suvivors = 0;
int FinalSuvivors = 0;
int Next_Person = 0;
int Starting_Point = 0;
int Current_Point = 0;
char People[] = "abcdefghijklmnopqrstuvwxyz";

int choice;
bool gameOn = true;
while (gameOn != false)
{
cout << "\tJosephus Problem\n" << endl;

cout << "*******************************\n";
cout << " 1 - Start the game.\n";
cout << "*******************************\n";
cin >> choice;

switch (choice)
{
case 1:
cout << "game start!\n";

break;
}

cout << "Enter Number of People: ";
cin >> NumberofPeople;
while (NumberofPeople > 26)
{
cout << "ERROR: The Number of People is Too Big." << endl;
cout << "Number of People Can Not Be No More than 26 (a thru z)" << endl;
cout << "Enter Number of People: ";
cin >> NumberofPeople;
}




cout << "Skip Number Can Not Be No More than 25." << endl;
cout << "Enter Skip Number: ";
cin >> skip;

while (skip > 25)
{
cout << "ERROR: The Skip Number is Too Big." << endl;
cout << "Skip Number Can Not Be No More than 25." << endl;
cout << "Enter Skip Number: ";
cin >> skip;

}

cout << "People: ";
for (int i = 0; i < NumberofPeople; i++)
{
Suvivors++;
cout << People[i];

}

cout << endl;
cout << "Skip Number : " << skip << endl;
cout << "---------------------------------------" << endl;

while (Suvivors != skip)
{
cout << "Suvivors : ";
for (int i = 0; i <= Suvivors - 1; i++)
{
cout << People[i];
}

cout << " " << People[Starting_Point] << " kills " << People[(Starting_Point + skip) % Suvivors] << endl;
Starting_Point = (Starting_Point + skip) % Suvivors;

Suvivors--;
cout << FinalSuvivors%Suvivors;
}

cout << "Final survivors: ";

for (int i = 0; i < Suvivors; i++)
cout << People[i];
{


}
cout << endl;


}
}


Last edited on
Topic archived. No new replies allowed.