由买买提看人间百态

topics

全部话题 - 话题: newlength
(共0页)
x****a
发帖数: 1229
1
作业,创建rectangle class, 要求 throw exceptions, 我的code如下:
public class rectangle extends Shape{
public Rectangle ()
{
this(Shape.DEFAULT_SIZE, Shape.DEFAULT_SIZE);
}

public Rectangle (double newLength, double newWidth)
{
this(Rectangle.RECTANGLE_NAME, newLength, newWidth);
}
protected Rectangle (String newName, double newLength, double newWidth)
{
super (newName);

try
{
this.setLength (newLength);
... 阅读全帖
l**b
发帖数: 457
2
Exception本身就是implements了Throwable了的,你extends和implements达到的效果
都是一样的。
我试了你的code,没有你说的问题啊?
Shape.java:
public class Shape {

public static final double DEFAULT_SIZE = 1.0;

private String name;

public Shape(String name) {
this.name = name;
}
}
Rectangle.java:
public class Rectangle extends Shape {

public static final String RECTANGLE_NAME = "Rectangle";

private double length;
private double width;

public Rectangle ()
{
this(S... 阅读全帖
l*********8
发帖数: 4642
3
来自主题: JobHunting版 - 贡献一道G家的面试题
bool Convert(char * buf, int bufSize)
{
int length = strlen(buf);
int newLength = length;
for (int i=0; i if (buf[i] == 'A')
newLength--;
else if(buf[i] == 'B')
newLength++;
if (newLength > bufSize - 1) return false;
int w = newLength-1;
for (int r = length-1; r>=0; r--) {
if(buf[r] != 'A')
buf[w--] = buf[r];

if (buf[r] == 'B')
buf[w--] = buf[r];
}
buf[newLength] = '\0';
return true;
}
S*********g
发帖数: 5298
4
来自主题: Science版 - Re: 问个数学问题
Sorry,没有注释,也许会难懂些.
对了,我这个还有个WEIGHT,就是如果是偶次对换出来的就是1,否则是-1
fullorder[object_, result_, weight_] :=
Module[{NewObject, NewResult, NewWeight, NewLength, objectlength,
firstobject, i, j,},
objectlength = Length[object];

If[objectlength == 1, result = {object}; weight = {1},
firstobject = object[[1]];
NewObject = Delete[object, 1];
NewLength = Factorial[objectlength - 1];
fullorder[NewObject, NewResult, NewWeight];
I*******l
发帖数: 203
5
来自主题: JobHunting版 - 贡献一道G家的面试题
I am confused here: it seems you may erase some of the original characters
in the string. For example, if newLength < length, then starting from the
end, you will overwrite the characters that have not been processed.
m********a
发帖数: 559
6
来自主题: JobHunting版 - 贡献一道G家的面试题
有bug吧?如果newlength < length,你中间把原值覆盖了。前面一位说的先去A,再添
B应该是正确解法吧。
h*****0
发帖数: 4889
7
来自主题: Programming版 - java的内存管理真是气死我了
int[] buffer
长度不够时
int[] oldBuffer = buffer;
buffer = new int[newLength];
copy oldBuffer to buffer
java数组是动态new的,又不是声明多长是多长,怕什么长度不够?
b*******h
发帖数: 56
8
这个也不行,但是我发现了http://www.tug.org/TeXnik/mainFAQ.cgi?file=space/space
的一处错误,校正后现在我能够修改章节标题上下边距了,但是我还是不能修改table
of contents,list of figure,list of table 这几个标题的上下边距!!!
还请指点
附上正确的程序
其实网上的程序只是缺了一个%。。。
\makeatletter
\usepackage{calc}
\newlength{\topspace}
\setlength{\topspace}{-1in% <---- the whole vertical space
-\topmargin% <--- predefined
-\headheight% ...
-\headsep% ...
-\topskip}% ...
\def\@makechapterhead#1{%
\vspace*{\topspace}% <---- the spac
c*******h
发帖数: 1096
9
来自主题: TeX版 - 问个自定义符号的文问题
\newlength{\wdo}
\newcommand{\checkline}[1]{\check{#1}%
{\settowidth{\wdo}{$\overline{#1}$}\kern-\wdo}%
\overline{\phantom{#1}}}
(共0页)