题目
思路
用double型储存,求出每个数的实部和虚部平方和的开方,找最大值。固定两位小数输出就直接AC了,不用再进行一次round四舍五入。
AC代码
#include<bits/stdc++.h>
using namespace std
;
int main(){
int n
; cin
>>n
;
double a
,b
,m
;
double max
=0;
for(int i
=0;i
<n
;i
++){
cin
>>a
>>b
;
m
=sqrt(a
*a
+b
*b
);
if(m
>max
) max
=m
;
}
cout
<<fixed
<<setprecision(2)<<max
;
return 0;
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-12468.html