Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 15th, 2012  |  syntax: C++  |  size: 0.81 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream.h>
  2. #include <math.h>
  3.  
  4. void main () {
  5.         int r, i, j, exrs1, exrs2, a[5][3];
  6.         int count = 0;
  7.         cout << "\nRadius:";
  8.         cin >> r;
  9.         cout << "\nCoordinates:";
  10.  
  11.         for(i = 1; i <= 5; i++) {
  12.                 cout << "\nx = ";
  13.                 cin >> a[i][1];
  14.                 cout << "y = ";
  15.                 cin >> a[i][2];
  16.                 a[i][3] = 0;
  17.         }
  18.  
  19.         for(i = 1; i <= 5; i++) {
  20.                 for(j = 1; j <= 5; j++) {
  21.                         exrs1 = a[j][1] - a[i][1];
  22.                         exrs2 = a[j][2] - a[i][2];
  23.                         if (r*r >= exrs1*exrs1 + exrs2*exrs2)
  24.                                 //a[i][3]=a[i][3]+1;
  25.                                 a[i][3]++;
  26.                 }
  27.         }
  28.        
  29.         for(i = 1; i <= 5; i++) {
  30.                 if(count == 2)
  31.                         break;                 
  32.                 for(j = 1; j <= 5; j++) {
  33.                         if(count == 2)
  34.                                 break;
  35.                         if (a[i][3] == a[j][3]) && i != j) {
  36.                                 cout << "\n" << i << " and " << j;
  37.                                 count++;
  38.                         }
  39.                 }
  40.         }
  41.  
  42.         //for(i = 1; i <= 5; i++)
  43.         //      cout << "\n" << i << " = " << a[i][3];         
  44. }