两道简单题,此外,1049有网友给出的计算公式是 Z=3.14*(x*x+y*y)/100.0+1.0,可惜我不明白其原理
ZOJ1045 HangOver
#include
<
iostream
>
using
namespace
std;
int
main()
{
double
target,num,sum;
while
(cin
>>
target
&&
target
!=
0.00
)
{
sum
=
0.0f
;
num
=
2
;
while
(sum
<
target)
{
sum
+=
1.0
/
num;
num
++
;
}
cout
<<
num
-
2
<<
"
card(s)
"
<<
endl;
}
return
0
;
}
ZOJ1048 Financial Management
#include
<
iostream
>
using
namespace
std;
int
main()
{
double
sum
=
0.0f
,average
=
0.0f
,num;
for
(
int
i
=
0
;i
<
12
;
++
i)
{
cin
>>
num;
sum
+=
num;
}
average
=
sum
/
12.0f
;
cout
<<
"
$
"
<<
average
<<
endl;
return
0
;
}