avatar
木板床# Living
o*d
1
http://discuss.leetcode.com/questions/192/string-to-integer-ato
Am I right?
We can separate INT_MAX and INT_MIN to first n-1 digits and last one digit,
which can be used to check overflow before the answer really overflows. Note
that abs(INT_MIN)=INT_MAX+1.
class Solution {
public:
int atoi(const char *str) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int pos=0;
//skip whitespace
while(str[pos]==' ')pos++;
//check if negative
int negative=0;
if(str[pos]=='-')
{
negative=1;
pos++;
}
else if(str[pos]=='+')
pos++;
if(str[pos]=='\0') return 0;
//separate INT_MAX to first n-1 digits and the last one digit
//INT_MIN as well
//NOTE that abs(INT_MIN) = INT_MAX + 1
int max1, max2, min1, min2;
max1=INT_MAX/10;
max2=INT_MAX-max1*10;
if(max2+1==10)
{
min1=max1+1;
min2=0;
}
else
{
min1=max1;
min2=max2+1;
}
int ans=0;
while(isdigit(str[pos]))
{
//check if overflow
if(!negative)
{
if(ans>max1 || ans==max1&&(str[pos]-'0')>=max2)
return INT_MAX;
}
else
{
if(ans>min1 || ans==min1&&(str[pos]-'0')>=min2)
return INT_MIN;
}
ans = ans*10+(str[pos]-'0');
pos++;
}
if(negative) ans=-ans;
return ans;
}
int isdigit(char c)
{
if(c>='0' && c<='9')
return 1;
else
return 0;
}
};
avatar
s*n
2
有大侠提到:
many people also suggested get a 4X8 ft 五层甲板, cut into 48X80 in(queen
size), then add a memory foam topper.
请问五层甲板用英文怎么说,有和特殊要求?
谢谢
avatar
r*e
3
5 ply。 一般3/4 inch plywood 好像都是5 ply。做床板至少要BC grade的。如果下面
有2x4钉的frame,那用 half inch plywood就行。
不过...48x80的queen size是不是小了点?
avatar
s*n
4
谢谢您的回复。但是,不太清楚什么是“2x4钉的frame”。
买的实际是高低床,想在上面给小孩放玩具,以后有二宝长大也可以当床板。上面的床
倒是有很多(8条以上吧)横着的木头了。那个尺寸是别人发的,我的还要具体量。

【在 r*****e 的大作中提到】
: 5 ply。 一般3/4 inch plywood 好像都是5 ply。做床板至少要BC grade的。如果下面
: 有2x4钉的frame,那用 half inch plywood就行。
: 不过...48x80的queen size是不是小了点?

avatar
a*3
5
plywood 做床板最省事,不过不透气,我拚了个 king size,跟睡在塑料布上一样。打
算等爸妈来了,让他们帮助搞个木条的床板,然后狠心买个棉褥子
avatar
r*e
6
高低床还是queen size的?贴个图吧

【在 s********n 的大作中提到】
: 谢谢您的回复。但是,不太清楚什么是“2x4钉的frame”。
: 买的实际是高低床,想在上面给小孩放玩具,以后有二宝长大也可以当床板。上面的床
: 倒是有很多(8条以上吧)横着的木头了。那个尺寸是别人发的,我的还要具体量。

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