- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
void signalclear(int noise[], int star[], int clear[]) {
int i = 0;
int j = 0;
while (clear[i] != -1) {
if (star[j] == -1) {
j = 0;
}
if (noise[i] == -1) {
clear[i] = -1;
break;
}
clear[i] = noise[i] - star[j];
i++;
j++;
}
}
它应该从 noise[]
中减去 star[]
直到达到 -1
,star[] 更短,所以它必须从头开始重新启动,直到 noise[]
达到 -1
,然后它将停止。
输入看起来像这样,但我现在使用的是实验值,您可以在下面看到它们。
(noise[])
382 450 402 490 592 652 712 832 422 370 362 450 512 512 512 532 683 694 700
712 789 509 480 540 512 469 450 412 402 422 462 522 -1
(star[])
120 120 140 160 200 260 320 440 160 40 100 120 120 -1
所以现在它在达到第一个 -1 后停止 {10,0,20,-1}
但它应该重新启动并继续减去,直到另一个序列达到 -1。
ERROR: signalclear({30,10,40,40,20,30,30,30,-1},{10,0,20,-1},{...}) // this sequence of numbers is only for testing.
Expected Result: {...} = {20,10,20,30,20,10,20,30,-1}
My Result: {...} = {20,10,20,30,-1}
最佳答案
您的代码中有两个问题。
1
开始,而不是从 0
开始。The "star" one is shorter so it has to restart from its beginning until "noise" hits '-1', then it will stop.
你没有正确处理这个问题。
如果我正确理解你的问题。下面的代码应该符合您的预期。
void signalclear(int noise[64], int star[64], int clear[64]) {
int i = 0;
int j = 0;
while (i < 64) {
if (star[j] == -1) {
j = 0; //Reset the j to start from the beginning.
}
if (noise[i] == -1) {
clear[i] = -1;
break;
}
clear[i] = noise[i] - star[j];
i++;
j++;
}
}
这就是我从main
调用的方式
void main()
{
int noise[64] = {30,10,40,40,20,30,30,30,-1};
int star[64] = {10,0,20,-1};
int clear [64];
signalclear(noise,star,clear);
int i=0;
for (i=0; i<64 && clear[i-1] != -1; i++)
printf("%d ", clear[i]);
}
输出:20 10 20 30 20 10 20 30 -1
关于无法弄清楚我的代码有什么问题:\(Array subtraction in C),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52645390/
我正在用java创建一个分数类。该程序采用整个分数表达式,并根据带有 switch 语句的运算符执行操作。我一切正常,除了当程序给出一个减法表达式(即 -1/2--1/2)时。当我测试这个表达式时,我
我目前正在开发一个使用 JavaFX 播放视频的应用程序。我想将音量 slider 放置在边框 Pane 的右侧。目前,应用程序将调整大小以适应窗口的大小,该窗口将与我的音量 slider 重叠。 我
import cv2 image1 = cv2.imread('one.jpg', 0) image2 = cv2.imread('two.jpg', 0) diff = image1 - ima
假设我有以下两个字符串: var value = "1-000-111"; var mask = " - -"; 我想从值中减去掩码。换句话说,我想要这样的东西: var output = sub
全部, 我有以下长格式数据框: df = pd.DataFrame({'date': ["2020-01-01","2020-01-01","2020-01-02","2020-01-02","202
我是 scala 新手,正在尝试编写函数,该函数返回给定字符串中每个字母的所有索引的映射。我的代码: def group(string: String) = { val map = mutable
如何减去数组中每一行的向量? a <- array(1:8, dim=c(2,2,2)) a , , 1 [,1] [,2] [1,] 1 3 [2,] 2 4 ,
一个群扩展了幺半群的想法以允许逆。这允许: gremove :: (Group a) => a -> a -> a gremove x y = x `mappend` (invert y) 但是像自然
我有一个主表A,约有 900 万行。另一个表 B(相同结构)包含表 A 中的约 28K 行。从表 A 中删除 B 的所有内容的最佳方法是什么? 所有列(~10)的组合都是唯一的。没有更多的形式是唯一
我想为可减类型创建一个类型类,这样 值类型实现 Ord。 有一个减函数。 它支持 UTCTime、Double 和 Int(或可选的任何 Num 类型) 有一个 Delta 类型,它可能与源值类型不同
我有几个对象列表 List listA和List listB 。我需要减去listA和listB并获取listA和listB中不匹配的对象列表。如果两个列表具有相同的对象,我不应该得到任何值。我尝试使
首先,我对问题标题不明确表示歉意:原因是我无法识别工作中的数学过程。 简而言之,情况如下: 我有两个长度不同的向量:f1 和 f2。 我想按元素计算 f1 和 f2 之间的最小平方距离。 这是我的操作
我有两个元组列表,每个元组都由开始时间和结束时间(从纪元开始的秒数)组成,如下所示: list1= [(2,4), (7,10), (14,22)] list2 = [(1,3), (5,8), (9
void signalclear(int noise[], int star[], int clear[]) { int i = 0; int j = 0; while (clear[i] !
是否可以减一Region对象并将其从另一个对象中减去? 例如我有两个区域,region1(绿色)和 region2(红色): 我如何创建一个 region3,它只是 region1 的一部分而不是 r
我正在尝试使用 ListUtils.subtract(1,2) 从另一个列表中减去一个列表的值,但是我注意到减法从未发生,所以我一直在返回 1 中的所有元素。我认为这可能表明存在平等问题,但我的哈希码
我想对dataframe进行条件减法(如第一张图所示)。 基本上,这就是我想要做的: 减去我和你之间的食物和衣服的 col1 和 col2 的值,并为差异创建新的行。 因为第一行有'food'和'me
我使用 OpenCV 进行前景检测,但我想知道是否有人可以提供帮助。问题出在这两个参数上: 学习率在:bst.apply(currentFame, foregroungMask, learnRate)
我有一个脚本可以收集数据。我遇到了 TypeError: Timestamp subtraction must have the same timezones or no timezones 错误。我
我发布了 another question如果您需要一些上下文,请早点。看来我在这种方法上走错了路。 Addition chains可用于最小化对数字求幂所需的乘法次数。例如,a7 需要四次乘法。两个
我是一名优秀的程序员,十分优秀!