2021-01-19
在牛客打卡1天,今天学习:刷题 10 道
全部评论
#include<stdio.h>
void main() {
int a[10] = { 2,6,3,1,7,5,8,10 };
int b[10];
int k = -1;
//printf("hhjjhff");
int i = 0;
int j = 0;
int target = 11;
for (; i < 9; i++) {
for (j = i + 1; j < 9; j++) {
if (a[i] + a[j] == 11) {
k++;
b[k] = i;
k++;
b[k] = j;
}
}
}
int n = 0;
for (n = 0; n < k + 1; n++) {
printf("%d", b[n]);
}
}
相关推荐