小编Cha*_*oir的帖子

CSS线性渐变角度位置

在此输入图像描述

我正在尝试使用线性渐变创建有角度的背景。

但是,我只能弄清楚如何创建一个从左下角到右上角的白色区域。

background: linear-gradient(to right bottom, #ffffff 49.8%, #e0e0e0 50%);
Run Code Online (Sandbox Code Playgroud)

https://jsfiddle.net/bfq3vv6n/

但是,我希望白色区域从页面左侧的一半开始,而不是从底部开始,然后在右上角完成(参见图片了解我希望它的外观)

有谁知道我该怎么做?

css gradient background linear-gradients

5
推荐指数
1
解决办法
2321
查看次数

打印出2D数组

array = Array.new(10) { Array.new(10 , 0)}

array.each { |x| print x }
Run Code Online (Sandbox Code Playgroud)

打印出一行十行[0, 0, 0, 0, 0, 0, 0, 0, 0, 0].

如果我要改变printputs,我再拿到100 0页面向下.

如何在没有"[]"和","的单独行上打印出每个数组?

就像是:

0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 …
Run Code Online (Sandbox Code Playgroud)

ruby printing arrays puts

4
推荐指数
3
解决办法
3735
查看次数

在Ruby中生成与其他数字不相等的数字?

基本上我正在生成数字,它们不能等于我生成的任何其他数字.有没有更快的方法来做到这一点,因为它看起来有点荒谬.

谢谢

#possible generated values
x1 = 0
x2 = 1
x3 = 2

#generate co-ordinates
x4 = rand(7)
until x4 != x1 && x4 != x1+1 && x4 != x1+2 && x4 != x2 && x4 != x2+1 && x4 != x2+2 && x4 != x3 && x4 != x3+1 && x4 != x3+2 do
  x4 = rand(7)
end

#possible generated values
y1 = 0
y2 = 1
y3 = 2

y4 = rand(7)
until y4 != y1 && …
Run Code Online (Sandbox Code Playgroud)

ruby random numbers

2
推荐指数
1
解决办法
73
查看次数

while while循环没有离开循环?

我很确定这应该有用......但即使我输入0或1,它仍然要求我选择一种颜色.如果我输入0或1,我是愚蠢还是退出循环?

public static int setColour() {
    EasyReader keyboard = new EasyReader();
    int colour;
    do{
        colour = keyboard.readInt("Pick a colour (black = 0, white = 1): ");
    }while (colour != 0 || colour != 1);
    return colour;
}
Run Code Online (Sandbox Code Playgroud)

java do-while

2
推荐指数
1
解决办法
54
查看次数

如何从while循环返回2个布尔值?Java的

我尝试返回correctPiece和correctDest但是

return correctPiece;
Run Code Online (Sandbox Code Playgroud)

加下划线并出现错误"无法访问的代码".

我怎么能两个都回来?

   while(correctPiece && !correctDest) {

            System.out.println("Click on a destination");

            toXCo = s.getToXInt();
            toYCo = s.getToYInt();

            Move found = null;

            for( Move m : moves){
                //checks if move can be done
                if (m.ToX() == toXCo && m.ToY() == toYCo){
                    //if move is allowed- exit loop
                    found = m; 
                    correctDest = true;
                }
            }

            if (found == null) {
                //if move can't be, ask for new co-ordinates
                System.out.println("This move is not legal \n");
                    correctDest = false;
                    correctPiece = …
Run Code Online (Sandbox Code Playgroud)

java boolean return while-loop

1
推荐指数
1
解决办法
2998
查看次数