- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
void function(int first[], int second[], int third[]) {
int i;
for(i=0;i<64;i++) {
third[i] = first[i] - second[i];
}
}
我想从第一个数组中减去第二个数组。第一个包含 32 个数字,第二个包含 13 个数字。对于前 13 个数字来说效果很好。一旦第二个数组“用完”元素,我想使用第二个数组开头的数字。所以我想从第一个数组的第 14 个元素中减去第二个数组的第一个元素,依此类推...我怎样才能实现它?
最佳答案
你可以使用%
从数组的长度中获取索引的余数,这样,你就可以循环遍历第二个数组了!我更改了您的代码以按照您的要求进行
// get the length of array before you pass it to the function like this:
// int second_len = sizeof(second) / sizeof(second[0]);
void function(int first[], int second[], int third[], int second_len) {
int i;
for(i=0;i<64;i++) {
third[i] = first[i] - second[i % second_len];
}
}
关于c - c中不同大小的数组相减,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52682044/
这个问题已经有答案了: Diff of two Dataframes (8 个回答) 已关闭 4 年前。 我有 2 个数据框(df_a 和 df_b),有 2 列:“动物”和“名称”。 在更大的数据框
如果我得到以下数字字符串,是否可以使用 LINQ 查询将这些数字一起加/减? string numbers = "1 + 1, 2 - 1, 3 + 3"; 所以我最终会得到这样的东西: 字符串数字
具有以下对象列表: public class Example { public string Local { get; set; } public string Type { get;
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
#include #include float sum (float *A, int len) // sum of table of floats { float ss = 0.0;
我正在阅读这篇博文:https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times-by-70/ 我很困惑: size_t len = end
我正在阅读这篇博文:https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times-by-70/ 我很困惑: size_t len = end
这个问题已经有答案了: Pointer Arithmetic In C (2 个回答) Pointer subtraction confusion (8 个回答) 已关闭 4 年前。 int vect
我知道这可能是个愚蠢的问题,但我遇到了一些麻烦,我很惭愧,但我真的不知道如何做到。我想加减两个以整数形式给出的“小时”。 #include #include #include using nam
大家好 StackOverflow.. 这个网站相当新,但我得到了很好的反馈!所以首先要感谢大家! 我想做的是类似于wonga的事情 https://www.wonga.com/ 但是随着值的协同工作
我是一名优秀的程序员,十分优秀!