Please help me to do question 19 by using PYTHON. And the code below is the code that does not suit for python, maybe you can help me out on why it cannot be use for python or provide me a new code. Thanks a lot #include using namespace std; string players[20]; int arr[20],ptr=1; void add(string name,int score); void showPlayers(); int search(string player); void removes(string player); int main () { int ch,score; string name; while(1) { cout<<"Choose option"<>ch; switch(ch) { case 1: cout<<"Enter player name and score"<>name; cin>>score; add(name,score); break; case 2: showPlayers(); break; case 3: cout<<"Enter player name"<>name; search(name); break; case 4: cout<<"Enter player name"<>name; removes(name); break; case 5: exit(0); default:cout<<"wrong choice Enter again"<
Please help me to do question 19 by using PYTHON. And the code below is the code that does not suit for python, maybe you can help me out on why it cannot be use for python or provide me a new code. Thanks a lot #include using namespace std; string players[20]; int arr[20],ptr=1; void add(string name,int score); void showPlayers(); int search(string player); void removes(string player); int main () { int ch,score; string name; while(1) { cout<<"Choose option"<>ch; switch(ch) { case 1: cout<<"Enter player name and score"<>name; cin>>score; add(name,score); break; case 2: showPlayers(); break; case 3: cout<<"Enter player name"<>name; search(name); break; case 4: cout<<"Enter player name"<>name; removes(name); break; case 5: exit(0); default:cout<<"wrong choice Enter again"<
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Please help me to do question 19 by using PYTHON.
And the code below is the code that does not suit for python, maybe you can help me out on why it cannot be use for python or provide me a new code. Thanks a lot
#include <bits/stdc++.h>
using namespace std;
string players[20];
int arr[20],ptr=1;
void add(string name,int score);
void showPlayers();
int search(string player);
void removes(string player);
int main ()
{
int ch,score;
string name;
while(1)
{
cout<<"Choose option"<<endl;
cout<<"1 .Add a new player and score"<<endl;
cout<<"2 .Print all players and scores"<<endl;
cout<<"3 .Search for a player score"<<endl;
cout<<"4 .Remove a player and score "<<endl;
cout<<"5 .Quit"<<endl;
cin>>ch;
switch(ch)
{
case 1: cout<<"Enter player name and score"<<endl;
cin>>name;
cin>>score;
add(name,score);
break;
case 2: showPlayers();
break;
case 3: cout<<"Enter player name"<<endl;
cin>>name;
search(name);
break;
case 4: cout<<"Enter player name"<<endl;
cin>>name;
removes(name);
break;
case 5: exit(0);
default:cout<<"wrong choice Enter again"<<endl;
}
}
}
void add(string name,int score)
{
players[ptr]=name;
arr[ptr]=score;
ptr++;
}
void showPlayers()
{
int i=1;
cout << "player" << setw( 13 ) << "score" << endl;
while(i<ptr)
{
cout << players[i] << setw( 13 ) << arr[i]<< endl;
i++;
}
}
int search(string name)
{
int i=1,found=0;
while(i<ptr)
{
if(players[i]==name)
{
cout<<"score: "<<arr[i]<<endl;
found=1;
return i;
}
i++;
}
if(found==0)
{
cout<<"the player's name was not entered";
return 0;
}
}
void removes(string name)
{
int i;
i=search(name);
if(i)
{
while(i<ptr)
{
players[i]=players[i+1];
arr[i]=arr[i+1];
i++;
}
ptr--;
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY