我正在尝试获取 3 个数组并添加每个元素组合以查看是否有任何等于 91,并且必须确保结果的红色值小于蓝色值小于绿色值。我一生都无法想到如何存储这么多实例,然后在最后引用它们。
如您所见,我缺少代码,因为我不知道如何继续。
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void) {
int i = 0;
int j = 0;
int k = 0;
int redSize = 6;
int blueSize = 9;
int greenSize = 9;
int red[] = (9, 22, 21, 18, 34, 13);
int blue[] = (20, 60, 14, 17, 39, 16, 6, 33, 18);
int green[] = (40, 7, 51, 26, 8, 24, 12, 11, 27);
for(i; i < redSize; i++){
result = red[i] + blue[j] + green[k]
while (j < blueSize){
// need to iterate over each item in array "blue"
while(k < greenSize){
//same for green
}
}
if (result == 91 && red[i] < blue[i] && blue[i] < green[i]){
printf("The red value is %d, the blue value is %d, and the green value is %d", red[i], blue[i], green[i]);
}
return 0;
}
}