void addEff(int val1[], int val2[], int val3[], int pos1[], int pos2[], int pos3[], int k1, int k2){ //access to each element in pos1[] and check if it has same position in pos2[] //if pos2[]has smaller value of position, add val2[] first before add val1[] int count=0; int i=0; int j=0; while (i<k1){ while (pos2[j]<=pos1[i]){ if (pos2[j]<=pos1[i]){ val3[count]+=val2[j]; pos3[count]=pos2[j]; j++; break; } val3[count]+=val2[j]; pos3[count]=pos2[j]; count++; j++; } val3[count]+=val1[i]; pos3[count]=pos1[i]; count++; i++; } }
举报
int input_val1[] = {11,22,33}; int input_pos1[] = {1,2,7}; int input_val2[] = {44,55,66}; int input_pos2[] = {2,4,6}; 那val3应该是 复制int expected_output_val[6]={11, 66, 55, 66, 33,0}; int expected_output_pos[6]={1, 2, 4, 6, 7,0};
int expected_output_val[6]={11, 66, 55, 66, 33,0}; int expected_output_pos[6]={1, 2, 4, 6, 7,0};
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
等级类勋章
发帖类勋章
时间类勋章
3
195
1
扫码关注 21ic 官方微信
扫码关注嵌入式微处理器
扫码关注电源系统设计
扫码关注21ic项目外包
扫码浏览21ic手机版
本站介绍 | 申请友情链接 | 欢迎投稿 | 隐私声明 | 广告业务 | 网站地图 | 联系我们 | 诚聘英才
京公网安备 11010802024343号