程序输出: printf("%ld \n",hash(str)); 其中函数hash为: unsigned long hash(unsigned char *str) { unsigned long hash = 5381; int c; while (c = *str++){ hash = ((hash << 5) + hash) + c; } // hash * 33 + c return hash; } 为什么输出有时候为负值?
程序如下: main() { long int a[2],i; for(i=0;i<2;i++) { scanf("%x",&a); printf("%d",a/2); } } 如果两个数都输入b,结果一个等于6一个等于5.如果是f,那就一个是7第二个是8,把long去掉一切都正常! 不知哪位大侠有什么意见啊? turboc 2.0
本人要写一个将很长的字符串写入long型数据段的程序。该字符串很大,可能有10000个左右,只知道要用流的方法来做,不知道程序如何写? 存取CLOB的程序如下: String sql1 = "select * from table1 for update" ; java.sql.PreparedStatement pstmt = null; pstmt = connection.prepareStatement(sql1); System.out.println("pstmt=" + pstmt); rs = pstmt.executeQ...
前两天碰到的,我是用异或来做的,不知道有没有其它更简单的方法? void ifTwothPower(const long int n) { int i; int compareto = 1; for (i = 0; i < 64; i++) { if ( !(n^compareto) ) { std::cout << i << std::endl; break; } compareto <<= 1; } } 当时是想如果是2的N次方,不考虑符号的问题,所有bit位的和肯定为1,但是不知道怎么用c操作bit位。
使用perl的Getopt::long处理命令行 调用程序时, 如 test.pl -f *pm 这样的话,shell会将它解析 但Getopt::long得到的命令行参数,只是匹配"*pm"的第一个字符串, 有没什么方法解决该问题 在此先谢了^_^