怎么assert
办?例如在函数中:
private static int charAt(String s, int d) {
assert d >= 0 && d <= s.length();
if (d == s.length()) return -1;
return s.charAt(d);
}
Run Code Online (Sandbox Code Playgroud) 我在Unix中用C编程,我gets
用来读取键盘的输入.我总是得到这个警告,程序停止运行:
warning: this program uses gets(), which is unsafe.
Run Code Online (Sandbox Code Playgroud)
谁能告诉我为什么会这样?
我试图了解3路基数Quicksort,我不明白为什么CUTOFF变量存在?和插入方法?
public class Quick3string {
private static final int CUTOFF = 15; // cutoff to insertion sort
// sort the array a[] of strings
public static void sort(String[] a) {
// StdRandom.shuffle(a);
sort(a, 0, a.length-1, 0);
assert isSorted(a);
}
// return the dth character of s, -1 if d = length of s
private static int charAt(String s, int d) {
assert d >= 0 && d <= s.length();
if (d == s.length()) return -1;
return s.charAt(d);
}
// 3-way …
Run Code Online (Sandbox Code Playgroud) 我正在使用openGL进行小组工作,当我尝试打开我的合作伙伴给我的文件时,我有这个错误:
-------------- Build:CG中的调试---------------
链接控制台可执行文件:bin/Debug/CG ld:找不到-lGL的库collect2:ld返回1退出状态进程终止,状态为1(0分,0秒)0错误,0警告
我在他的电脑上看到了相同的代码.是因为他在Windows工作吗?我在MacOSX工作?我正在使用CodeBlocks IDE.
谁能帮我解决这个问题?