Skip to content

Instantly share code, notes, and snippets.

@wcspoiler
Created October 22, 2013 19:36
Show Gist options
  • Save wcspoiler/7106796 to your computer and use it in GitHub Desktop.
Save wcspoiler/7106796 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
void main ()
{
float x1[]={345, 3367, 46, 7867, 356343, 535, 45345164, 234, 34214};
float y1[]={634, 1489, 4589, 42, 13560, 3421, 21, 1234, 234214, 4214231};
float xc[100], yc[100], r[100][100];
float rad;
int a[100][100], b[100][100], i, j, n, m, w;
rad=44444;
w=0;
n=7;
m=7;
for(i=0; i<n; i++)
{
xc[i]=x1[i];
yc[i]=y1[i];
}
printf(" \n CENTRI \n");
for(i=0; i<n; i++)
printf("\n xc[i]=%.0f \n yc[i]=%.0f \n", xc[i], yc[i]);
//матрица расстояний
for(i=0; i<n-1; i++)
for(j=i+1; j<n; j++)
r[i][j]= sqrt((xc[i]-xc[j])*(xc[i]-xc[j])+(yc[i]-yc[j])*(yc[i]-yc[j]));
printf(" \n RASSTOVANIYA \n");
printf(" \n ");
for(i=0; i<n-1; i++)
{
for(j=i+1; j<n; j++)
printf(" %.0f", r[i][j]);
printf(" \n" );
}
for(i=0; i<n-1; i++)
{
for(j=i+1; j<n; j++)
if(r[i][j]<(2*rad))
a[i][j]=1;
else a[i][j]=2;
}
printf(" \n" );
printf(" \n UNIJENIYA \n");
printf(" \n" );
for(i=0; i<n-1; i++)
{
for(j=i+1; j<n; j++)
printf(" %.0d ", a[i][j]);
printf(" \n" );
}
//44444444444444444
for(i=0; i<n; i++){
for(j=0; j<n; j++)
b[i][j]=1;
}
for(i=0; i<n; i++){
for(j=i; j<n; j++)
b[i][j]=3;
}
printf(" \n UNIJENIYA 2 \n");
printf(" \n" );
for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
printf(" %.0d ", b[i][j]);
printf(" \n" );
}
scanf(" %d", w);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment