小编Iły*_*sov的帖子

是否可以使用jGraphT检查TicTacToe游戏的获胜条件?

我发现这个有效的解决方案

private int[] winningPatterns = { 0b111000000, 0b000111000, 0b000000111, // rows
        0b100100100, 0b010010010, 0b001001001, // cols
        0b100010001, 0b001010100 // diagonals
};

/** Returns true if thePlayer wins */
private boolean hasWon(int thePlayer) {
    int pattern = 0b000000000; // 9-bit pattern for the 9 cells
    for (int row = 0; row < 3; ++row) {
        for (int col = 0; col < 3; ++col) {
            if (cells[row][col].content == thePlayer) {
                pattern |= (1 << (row * 3 + col));
            }
        } …
Run Code Online (Sandbox Code Playgroud)

java jgrapht tic-tac-toe

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

为什么两个看似相同的hashmaps在gson序列化时会有不同的行为?

输入:

public static void main(String[] args) {

    final String key = "some key";
    final String value = "some value";

    Map<String, String> map1 = new HashMap<String, String>(){{put(key, value);}};
    System.out.println(new Gson().toJson(map1) + " " + map1.get(key));

    Map<String, String> map2 = new HashMap<>();
    map2.put(key, value);
    System.out.println(new Gson().toJson(map2) + " " + map2.get(key));
}
Run Code Online (Sandbox Code Playgroud)

输出:

null some value
{"some key":"some value"} some value

Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)

java hashmap gson

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

如何在整个应用程序中使用一个数据库连接对象?

我创建了这个返回连接对象的类.我用过MySQL数据库.

public class Connect_db {        
    public Connection getConnection(String db_name,String user_name,String password)
    {
        Connection con=null;
        try
        {
        Class.forName("com.mysql.jdbc.Driver");
        con=DriverManager.getConnection("jdbc:mysql://localhost/"+db_name+"?user="+user_name+"&password="+password);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        return con;        
    }
}  
Run Code Online (Sandbox Code Playgroud)

现在我想做的就是实例化这个类一次并得到连接对象.我想在整个应用程序中使用同一个对象.另一个解决方案也将受到赞赏.

java mysql odbc jdbc java-ee

10
推荐指数
1
解决办法
4万
查看次数

Chrome中的虚线

出于某种原因,当使用虚线边框样式制作线条时,Chrome会将结尾呈现为双点,这看起来很糟糕,特别是在短线上:

.text {
  border-bottom: 2px dotted #000;
}
Run Code Online (Sandbox Code Playgroud)
<span class="text">Hi</span><br/>
<span class="text">lll</span><br/>
<span class="text">22</span><br/>
Run Code Online (Sandbox Code Playgroud)

即使是简单的事情border-bottom: 2px dotted #000;也无效.我看到一些文章建议将左/右边框设置为透明,但看起来更糟糕的是它切掉了点的小角落.

不过,它在Firefox中看起来很好.有没有办法让它在Chrome中看起来不错,或者我运气不好?

css border dotted-line

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

为什么是 HSHELL_WINDOWDESTROYED、HSHELL_WINDOWCREATED?

MSDN - “ShellProc功能”,“RegisterShellHookWindow功能”:

 HSHELL_WINDOWCREATED   => A top-level, unowned window has been created.
 HSHELL_WINDOWDESTROYED => A top-level, unowned window is about to be destroyed.
Run Code Online (Sandbox Code Playgroud)

但:

当仅对任何顶级无主窗口(带有任务栏按钮)进行隐藏/显示(或设置/取消)时,我们也会得到HSHELL_WINDOWDESTROYED/ 。为什么?任务栏按钮不是“真正的”窗口,不是吗?HSHELL_WINDOWCREATEDWS_EX_TOOLWINDOW

这个问题主要针对MS内部人士。

winapi

5
推荐指数
0
解决办法
1177
查看次数

MySQL十进制字段'数据在第1行的第x列被截断'问题

我有一个带小数(16,2)字段的mysql表.看起来像使用另一个十进制(16,2)字段字符串的加法操作可能会导致Data truncated for column x at row 1问题,这会在我的django项目中引发异常.

我知道该字段的乘法或除法运算会导致此问题,因为结果可能不适合十进制(16,2)定义,但加法和减法操作是否相同?

我的MySQL服务器版本是5.5.37-0ubuntu0.14.04.1.您可以从下面重现此问题:

mysql> drop database test;
Query OK, 1 row affected (0.10 sec)

mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql> use test;
Database changed
mysql> create table t(price decimal(16,2));
Query OK, 0 rows affected (0.16 sec)

mysql> insert into t values('2004.74');
Query OK, 1 row affected (0.03 sec)

mysql> select * from t;
+---------+
| price   |
+---------+
| 2004.74 |
+---------+
1 …
Run Code Online (Sandbox Code Playgroud)

mysql sql decimal

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

为什么int的值会改变?

我有这个C代码:

int a = 5;
printf("a is of value %d before first if statement. \n", a);
if (a = 0) {
    printf("a=0 is true. \n");
}
else{
    printf("a=0 is not true. \n");
}
printf("a is of value %d after first if statement. \n", a);
if (a == 0){
    printf("a==0 is true. \n");
}
else{
    printf("a==0 is not true. \n");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

a is of value 5 before first if statement.
a=0 is not true. 
a is of …
Run Code Online (Sandbox Code Playgroud)

c

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

在arraylist中为每个字符串添加一个char

例如

String temp = "welcome,to,the,world,of,j2ee";
Run Code Online (Sandbox Code Playgroud)

将其转换为arraylist

ArrayList al= new ArrayList(temp.split(","));
Run Code Online (Sandbox Code Playgroud)

这是作为arraylist的内容 {"welcome","to","the","world","j2ee"}

我的要求是在每个字符串的末尾添加"^ d"

对于前 {"welcome^d","to^d","the^d","world^d","j2ee^d"}

java arrays string

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

使用不同的关键词,SQL

当我写查询时:

SELECT DISTINCT City FROM Customers;
Run Code Online (Sandbox Code Playgroud)

它返回Customers表中的所有不同城市.

但是当我写下查询时:

SELECT DISTINCT City,* FROM Customers;
Run Code Online (Sandbox Code Playgroud)

它返回Customers表中的所有行(首先是城市列,后面是所有列,包括city).

即使我们使用不同的关键字,显示所有记录的原因是什么?

sql distinct

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

请解释此错误日志

我在godaddy中拥有域,并且我试图在专用服务器中安装脚本或尝试访问我的域righttimematrimony.com,但该域未加载并显示错误。一次,我的网站加载并显示sci-bin文件夹,将数据上传到服务器并尝试访问我的网址后,但显示了很多错误。请有人帮助我现在该怎么办。

这是在Cpanel->错误日志中的错误日志中的数据。

[Mon Dec 29 04:14:23 2014] [alert] [client 106.66.138.199] /home/right/public_html/.htaccess: Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration
[Mon Dec 29 04:14:23 2014] [alert] [client 106.66.138.199] /home/right/public_html/.htaccess: Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration
[Mon Dec 29 04:14:05 2014] [alert] [client 106.66.138.199] /home/right/public_html/.htaccess: Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration
[Mon Dec 29 …
Run Code Online (Sandbox Code Playgroud)

apache .htaccess server

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

为什么程序打印0.00

提出的问题是:"考虑下一个问题,创建一个计算2个月内能源消耗的问题:

  1. 如果废物小于每小时1000千瓦,则乘以1.2
  2. 如果废物在每小时1000到1850千瓦之间,则乘以1.2.
  3. 如果废物大于每小时1850kw,则乘以0.9

我写了这个程序,当我运行它并添加浪费和小时的值时,无论我输入哪个值,费用都会给我0.00.

#include <stdio.h>
#include <math.h>

int main()
{
   int c; //energy waste//
   float p, h; // p=fee h=hours//

   printf("Introduce el consumo y el numero de horas:");
   scanf("%d %f ", &c, &h);

   if (c<1000) {
        p=h*1.2;
   }
   if ((c=1000) && (c<1851)) {
        p=h*1.2;
   }
   if (c>1850) {
        p=h*0.9;
   }

   printf("Fee: %f", p);
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

我需要收取费用.我希望它写得很好,因为我讲西班牙语并且不熟悉英语中的编程概念.

c

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

无法解决以下Visual 2008

Dim a, b, c As Integer
a = 10
b = 3
c = a And b

MessageBox.Show(c)
Run Code Online (Sandbox Code Playgroud)

结果c = 2怎么来的?

vb.net

-3
推荐指数
1
解决办法
65
查看次数

在我的第二个if/else语句中有一个小故障,我想,你能帮我找到它吗?

在我的第二个if/else语句中有一个小故障,我想,你能帮我找到它吗?曾经的单词== 1单词的值应该改为"瓶子",但它正在打印"瓶子".


public class milkSong
{
    public static void main(String[] args) {
        int milkNum = 10; //decreased the bottles of milk so that the output would fit
        String word = "bottles";

        while (milkNum > 0) {

            if (milkNum == 1) { 
                word = "bottle"; 
            }

            System.out.println (milkNum + " " + word + " of milk on the wall.");
            System.out.println (milkNum + " " + word + " of milk.");
            System.out.println ("Take one down.");
            System.out.println ("Pass it around.");
            milkNum = …
Run Code Online (Sandbox Code Playgroud)

java

-3
推荐指数
1
解决办法
81
查看次数

标签 统计

java ×5

c ×2

mysql ×2

sql ×2

.htaccess ×1

apache ×1

arrays ×1

border ×1

css ×1

decimal ×1

distinct ×1

dotted-line ×1

gson ×1

hashmap ×1

java-ee ×1

jdbc ×1

jgrapht ×1

odbc ×1

server ×1

string ×1

tic-tac-toe ×1

vb.net ×1

winapi ×1