fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char * argv[])
  7. {
  8. int n = 12;
  9. int * v = new int[n];
  10. for(int i = 0; i < n; ++i)
  11. {
  12. int d = rand()%20;
  13. cout << setw(6) << d;
  14. v[i] = d;
  15. }
  16. cout << endl;
  17.  
  18. for(int i = 0; i < n-1; ++i)
  19. {
  20. for(int j = i+1; j < n; ++j) cout << setw(6) << (v[j] -= v[i]);
  21. cout << endl;
  22. }
  23.  
  24. }
  25.  
  26.  
Success #stdin #stdout 0s 5520KB
stdin
Standard input is empty
stdout
     3     6    17    15    13    15     6    12     9     1     2     7
     3    14    12    10    12     3     9     6    -2    -1     4
    11     9     7     9     0     6     3    -5    -4     1
    -2    -4    -2   -11    -5    -8   -16   -15   -10
    -2     0    -9    -3    -6   -14   -13    -8
     2    -7    -1    -4   -12   -11    -6
    -9    -3    -6   -14   -13    -8
     6     3    -5    -4     1
    -3   -11   -10    -5
    -8    -7    -2
     1     6
     5