thesonpb

tổng đôi

Mar 30th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void sapxep(int a[], int n){
  4.     for(int i=0; i<n-1; i++){
  5.         for(int j=i+1; j<n; j++){
  6.             if(a[i]>a[j]) swap(a[i], a[j]);
  7.         }
  8.     }
  9. }
  10. int main(){
  11.     int n;
  12.     cin >> n;
  13.     int a[10000];
  14.     for(int i=0; i<n; i++){
  15.         cin >> a[i];
  16.     }
  17.     sapxep(a, n);
  18.     for(int i=0; i<n-1; i++){
  19.         for(int j=i+1;j<n; j++ ){
  20.            
  21.                 if(a[i]+a[j]==0) cout<<a[i]<<" "<<a[j]<<endl;
  22.            
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment