anlinjie @ 2024-02-25 10:55:44
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int getSum(char score[],int len){ //获取总分
int sum=0;
int step=1;
for (int i=len;i>=1;){
if (score[i]>='0'&&score[i]<='9'){
sum+=score[i]-48;
step=1;
if (score[i-1]>='0'&&score[i-1]<='9'){
sum+=(score[i-1]-48)*10;
step=2;
if(score[i-2]>='0'&&score[i-2]<='9'){
sum+=(score[i-2]-48)*100;
step=3;
}
}
}else{
step=1;
}
i-=step;
}
return sum;
}
int main(){
int num;
cin>>num;
cin.ignore(); //吸收换行符
int max=-1;
int m=0;
char scores[num][30];
for (int i=0;i<num;i++){
cin.getline(scores[i],30);
int len=strlen(scores[i]);
int sum=getSum(scores[i],len);
if(sum>max){
max=sum;
m=i;
}
}
cout<<scores[m]<<endl;
return 0;
}
by QuQ_ @ 2024-02-25 12:33:58
@anlinjie 就一个点错了,建议打表