【发布时间】:2017-05-18 01:02:58
【问题描述】:
我已经制定了以下逻辑。最短运行:具有相同元素的原始数组的子数组。
// "A" is Array, p is length of a current run, q is global variable that stores lowest run length
procedure(){
while( i < sizeOfArray){
if(A[i]==A[i+1]){
//1.Increment a variable "p" to capture the length of run
//2. compare p and q and which ever is smaller , is saved into q
}else{
//3. What to do here ?
}
}
return q;
}
【问题讨论】:
-
仍然不是有效的 C 代码。您的问题表明您的逻辑“总是返回错误”。如果您还没有编写任何代码,这意味着什么?相关逻辑并未以您所展示的方式表达。你需要付出一些努力才能让任何人帮忙。
-
@DavidBowling 我重新表述了这个问题。问问题的动机是了解逻辑而不是编程代码。您可以使用任何语言来显示答案。谢谢
标签: c arrays algorithm sorting