:setw :需要填充多少个字符,默认填充的字符为' '空格
setfill:设置std::setw将填充什么样的字符,如:std::setfill('*')
举例:
cout<<setfill('0')<<setw(4)<<(*ans.first)[0]<<" "<<setw(4)<<(*ans.second)[0];
pat乙级1082:
#include<bits/stdc++.h>
using namespace std;
using gg = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
gg ni;
cin>>ni;
using Player = array<gg,3>;
vector<Player> v(ni);
for(int i =0;i<ni;i++){
cin>>v[i][0]>>v[i][1]>>v[i][2];
}
auto ans = minmax_element(v.begin(),v.end(),[](const Player& p1,const Player& p2){
return hypot(p1[1],p1[2])<hypot(p2[1],p2[2]);
});
cout<<setfill('0')<<setw(4)<<(*ans.first)[0]<<" "<<setw(4)<<(*ans.second)[0];
return 0;
}