#include<bits/stdc++.h>
using namespace std;
struct who{
int score;
string name;
int len;
}s[1010];
const int ck=200;
int cnt=0;
string op,whose;
int scorer;
void write(){
ofstream OutFile("存档.txt");
OutFile<<cnt<<endl;
for(int i=1;i<=cnt;i++){
OutFile<<s[i].score<<endl;
OutFile<<s[i].name<<endl;
OutFile<<s[i].len<<endl;
}
OutFile.close();
return;
}
void read(){
ifstream InFile("存档.txt");
InFile>>cnt;
for(int i=1;i<=cnt;i++){
InFile>>s[i].score;
InFile>>s[i].name;
InFile>>s[i].len;
}
return;
}
void setsize(int col, int row){
char cmd[64];
sprintf(cmd, "mode con cols=%d lines=%d", col, row);
system(cmd);
}
void print(){
if(cnt==0){
printf("There are no roles yet!\n");
return;
}
for(int i=1;i<=cnt;i++){
for(int j=1;j<=ck;j++){
putchar('-');
}
putchar('\n');
putchar('|');
for(int j=1;j<=s[i].len;j++){
putchar(s[i].name[j-1]);
}
printf("'s score:");
for(int j=1;j<=(51-s[i].len);j++){
printf(" ");
}
printf("%d\n",s[i].score);
}
for(int i=1;i<=ck;i++){
putchar('-');
}
putchar('\n');
return;
}
bool add(string who,int increasescore){
for(int i=1;i<=cnt;i++){
if(s[i].name==who){
return 0;
}
}
s[++cnt]={increasescore,who,who.size()};
return 1;
}
bool erase(string who){
for(int i=1;i<=cnt;i++){
if(s[i].name==who){
for(int j=i;j<=cnt;j++){
s[j]=s[j+1];
}
cnt--;
return 1;
}
}
return 0;
}
bool increase(string who,int increasescore){
for(int i=1;i<=cnt;i++){
if(s[i].name==who){
s[i].score+=increasescore;
return 1;
}
}
return 0;
}
void How_to_use(){
printf("How to use: \n\n\n1. Enter 'add', the name of the character and the initial score, if there is a character with the same name, it will return 'Roles are already present in the sequence!', otherwise the character will be imported into the database, and 'Roles are already present in the sequence!'; \n\n2. Enter 'erase' and the name of the character, if there is no role, it will return 'Role not found!', otherwise the character will be deleted, and return 'The deletion is successful!'; \n\n3. Enter 'print', if there is no role, return 'There are no roles yet!', and output the character's name and score; \n\n4. Enter 'increase', the name of the character and the score to be added, if there is no role, it will return 'Role not found!', otherwise the score of the character will be added to the entered score, and 'Increase success!' will be returned; \n\n5. Enter 'return' to end the use of this system.\n\n");
}
void main_interface(){
cin>>op;
if(op=="add"){
cin>>whose>>scorer;
if(add(whose,scorer)){
printf("Join successfully!\n");
}else{
printf("Roles are already present in the sequence!\n");
}
}else if(op=="erase"){
cin>>whose;
if(erase(whose)){
printf("The deletion is successful!\n");
}else{
printf("Role not found!\n");
}
}else if(op=="print"){
print();
}else if(op=="increase"){
cin>>whose>>scorer;
if(increase(whose,scorer)){
printf("Increase success!\n");
}else{
printf("Role not found!\n");
}
}else if(op=="return"){
printf("Welcome to use it next time! Good bye!\n");
write();
return;
}
main_interface();
}
int main(){
read();
system("color 3F");
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
setsize(ck,120);
How_to_use();
main_interface();
return 0;
}