当我在 Visual Studio 2015 中遇到 [Analyze -> Run Code Analysis] 提出的有趣问题时,我正尝试在 C 中实现合并排序。
代码如下:
void MergeSort_r(int A[], int n)
{
// A = {1, 3, 2}
// n = 3
int rightCount;
int* R;
if ( n < 2 ) return;
// version 1: rightCount = 2
rightCount = n - (n/2);
// version 2: rightCount = 2
rightCount = n - 1;
R = ( int* ) malloc( rightCount * sizeof( int ) );
if ( R ) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Scala在Udacity的CS212上工作,但在使用Zebra Puzzle时遇到了麻烦,
python中的一些概念并不容易转换为Scala,特别是对于像我这样的初学者.

这些是我到目前为止管理的代码,
val houses = List(1, 2, 3, 4, 5)
val orderings = houses.permutations
def imright(h1: Int, h2: Int): Boolean = {
if (h1 - h2 == 1) true
else false
}
def nextto(h1: Int, h2: Int): Boolean = {
if (math.abs(h1 - h2) == 1) true
else false
}
Run Code Online (Sandbox Code Playgroud)
the houses = [first, _, middle, _. _] = [1, 2, 3, 4, 5]难倒我 此外,我如何for (red, green, ivory, yellow, blue) in orderings在Scala中表达?请帮帮我,谢谢.
这在其他语言中通常是微不足道的,但我在Clojure中找不到这样的例子.
我可以使用以下方法打印整个文件:
(with-open [rdr (io/reader "file")]
(doseq [line (line-seq rdr) :while (< count(line) 10)]
(println line)))
Run Code Online (Sandbox Code Playgroud)
但是如何让它停在第5行呢?
谢谢.