avatar
p*e
1
【 以下文字转载自 FleaMarket 讨论区 】
发信人: pixie (pixie), 信区: FleaMarket
标 题: 寄点维生素和非处方药回国,怎么寄比较好?
发信站: BBS 未名空间站 (Tue Feb 15 23:44:53 2011, 美东)
请教。有关税么?
有包子。
avatar
k*r
2
function double sqrt(double d, int p). p is precision option. My code is as
follows. Please let me know if you see any error. Thanks,
public static double sqrt(double d, int p) {
if (d < 0) {
return Double.NaN;
}
double prec = Math.pow(10, - p);
double start = 0;
double end = d;
while (start < end) {
double mid = start + (end - start) / 2;
if (mid == 0) {
return mid;
}
if (mid * mid == d) {
return mid;
} else if (mid < d / mid) {
start = mid + prec;
} else {
end = mid - prec;
}
}
return start;
}
avatar
s*y
3
生完快5天了,在医院的头2天,宝宝吸奶很有力,每次吸不停,可是就一点初乳,压根
没吃到啥,还得
喂很多医院的液体奶。
现在的情况,开始电动泵奶2天,每天就2,3次。实在太累,每次1小时多,就80-100cc
左右。
请问过来的妈妈们,奈良算正常吗?
给宝宝胸喂,能吸饱吗?泵出来喂,是不好一点? 什么时候可以大量产奶啊? 头一周
什么汤催奶最好
呢?
新妈求教,谢谢!
avatar
r*w
4
粤语版
avatar
k*r
5
求教有人帮忙看看吗
avatar
s*x
6
for most of interview codes, if you have more than 10 lines, usually
something wrong.
1) for number less than 1 and great than one, it should be processed
differently.
2) why you need to check mid == 0?
3) why you need add prec to mid each time?
4) always compare with a precision for floats, do not compare directly.
avatar
k*r
7
大牛能否写个clean的code供学习一下。

【在 s**x 的大作中提到】
: for most of interview codes, if you have more than 10 lines, usually
: something wrong.
: 1) for number less than 1 and great than one, it should be processed
: differently.
: 2) why you need to check mid == 0?
: 3) why you need add prec to mid each time?
: 4) always compare with a precision for floats, do not compare directly.

avatar
s*x
8

google.

【在 k****r 的大作中提到】
: 大牛能否写个clean的code供学习一下。
avatar
k*r
9
你太牛了

【在 s**x 的大作中提到】
:
: google.

avatar
D*a
10
you code is wrong by checking "mid * mid == d"
you should return mid if abs(start-end)
as

【在 k****r 的大作中提到】
: function double sqrt(double d, int p). p is precision option. My code is as
: follows. Please let me know if you see any error. Thanks,
: public static double sqrt(double d, int p) {
: if (d < 0) {
: return Double.NaN;
: }
: double prec = Math.pow(10, - p);
: double start = 0;
: double end = d;
: while (start < end) {

avatar
k*r
11
right. Thanks for the hint.

【在 D*******a 的大作中提到】
: you code is wrong by checking "mid * mid == d"
: you should return mid if abs(start-end):
: as

avatar
s*x
12
if ( d < 0) return -1;
prec = ...;
start = d > 1 ? 1: d;
end = d > 1 ? d : 1;
While(1) {
m = (start + end) / 2;
v = m * m - d;
if(v > prec)
end = m;
else if( v < -prec)
start = m;
else
return m;
}
}
avatar
N*m
13
newton's method

as

【在 k****r 的大作中提到】
: function double sqrt(double d, int p). p is precision option. My code is as
: follows. Please let me know if you see any error. Thanks,
: public static double sqrt(double d, int p) {
: if (d < 0) {
: return Double.NaN;
: }
: double prec = Math.pow(10, - p);
: double start = 0;
: double end = d;
: while (start < end) {

avatar
k*r
14
thank you for the sharing. much more clear now.

【在 s**x 的大作中提到】
: if ( d < 0) return -1;
: prec = ...;
: start = d > 1 ? 1: d;
: end = d > 1 ? d : 1;
: While(1) {
: m = (start + end) / 2;
: v = m * m - d;
: if(v > prec)
: end = m;
: else if( v < -prec)

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。