#14241: 求助


buanyz03 (張晁瑋)

學校 : 新北市立板橋高級中學
編號 : 2629
來源 : [114.25.190.198]
最後登入時間 :
2023-09-06 15:43:50
c236. 旅行者_九國遊歷記<1> 小赤去鶴國 -- 106學年度板橋高中校內資訊學科能力競賽 | From: [60.248.142.208] | 發表日期 : 2018-07-04 11:30

 #include <iostream>
#include <vector>
#include <string>
#include <ctype.h>
#include <algorithm>
using namespace std;
struct word
{
string original,change;
int y;
};
bool gt(word a,word b)
{
if(a.y!=b.y)
{
return a.y<b.y;
}
return a.change<b.change;
}
int main()
{
vector <word> v;
word temp;
int t,n,k;
cin>>t;
while(t--)
{
cin>>n;
while(n--)
{
cin>>temp.original>>temp.y;
temp.change=temp.original;
for(int i=0;i<temp.change.size();++i)
{
if(isalpha(temp.change[i]))
{
temp.change[i]=tolower(temp.change[i]);
}
}
for(k=0;k<v.size();++k)
{
if(v[k].change==temp.change && v[k].y>temp.y)
{
v[k]=temp;
break;
}
}
if(k==v.size())
{
v.push_back(temp);
}
}
}
sort(v.begin(),v.end(),gt);
for(int i=0;i<v.size();++i)
{
cout<<v[i].original<<endl;
}
}

不知道錯在哪裡

 
ZeroJudge Forum