Untitled

 avatar
canhquydev
plain_text
2 months ago
439 B
0
Indexable
Never
#include <iostream>
using namespace std;
int main(){
    int arr[100];
    int n, k;
    do{
        cin >> n;
    }while(n < 2 || n > 10);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    cin >> k;
    for(int  i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            if(arr[i]+arr[j] == k){
                cout << i << " " << j;
                break;
            }
        }
    }
}
Leave a Comment