loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.4477208702319042","path":"main.c","file":{"path":"main.c","content":{"asEncoding":{"base64":"I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPG1hdGguaD4KCiNkZWZpbmUgcGxpdGhvc19zaW1laXduIDIwCiNkZWZpbmUgWG1pbiA3MTk2MDQuMCAKI2RlZmluZSBYbWF4IDcyMjUzOC4wIAojZGVmaW5lIFltaW4gNDMyODQ2OS4wIAojZGVmaW5lIFltYXggNDMzMjkwNy4wIAojZGVmaW5lIFJhZGl1cyA1MDAKI2RlZmluZSBUb3RhbF9SZWdpb25zIDIKCnN0cnVjdCBQb2ludF9vZl9JbnRlcmVzdAp7CiAgICBjaGFyIGlkWzEwXTsKICAgIGRvdWJsZSB4OwogICAgZG91YmxlIHk7Cn07CiAgCnN0cnVjdCBQb2ludF9vZl9JbnRlcmVzdCBQb2ludHNbcGxpdGhvc19zaW1laXduXTsKCmRvdWJsZSBEaXN0YW5jZXMgW3BsaXRob3Nfc2ltZWl3bl1bcGxpdGhvc19zaW1laXduXTsKCmRvdWJsZSBBdmVyYWdlX0Rpc3RhbmNlcyBbcGxpdGhvc19zaW1laXduXTsKCnZvaWQgRGF0YV9Qb2ludHMoKQp7CiAgICBpbnQgaTsKCWZvciAoaT0wO2k8cGxpdGhvc19zaW1laXduO2krKykKICAgIHsKICAgIAlwcmludGYoIkRvc2UgdG9uIGtvZGlrbyB0b3UgJWRvdSBzaG1laW91OlxuIixpKzEpOwogICAgCXNjYW5mKCIlcyIsUG9pbnRzW2ldLmlkKTsKICAgIAlkbwogICAgCXsKICAgIAkJcHJpbnRmKCJEb3NlIHRoIHggc2huaXN0b3NhIHRvdSAlZCBvdSBzaG1laW91Oig3MTk2MDQtNzIyNTM4KVxuIixpKzEpOwogICAgCQlzY2FuZigiJWxmIiwmUG9pbnRzW2ldLngpOwoJCX13aGlsZShQb2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Z2lvbnNbaV09MTAwOwoJCQlhdmVyYWdlMVtrMV09QXZlcmFnZV9EaXN0YW5jZXNbaV07CgkJCWsxKys7CgkJfQoJCWVsc2UKCQl7CgkJCVJlZ2lvbnNbaV09MjAwOwoJCQlhdmVyYWdlMltrMl09QXZlcmFnZV9EaXN0YW5jZXNbaV07CgkJCWsyKys7CgkJfQoJbWF4PWF2ZXJhZ2UxWzBdOwoJZm9yKGk9MTtpPGsxO2krKykKCQlpZihhdmVyYWdlMVtpXT5tYXgpCgkJCW1heD1hdmVyYWdlMVtpXTsKCXByaW50ZigiUGxpdGhvcyBrZXJhaW9uIHBvdSBwcmVwZWkgbmEgZWdrYXRhc3RhdGhvdW4gc3RobiBwZXJpb3hoIDE6JWxmXG4iLG1heC81MDApOwoJbWF4PWF2ZXJhZ2UyWzBdOwoJZm9yKGk9MTtpPGsyO2krKykKCQlpZihhdmVyYWdlMltpXT5tYXgpCgkJCW1heD1hdmVyYWdlMltpXTsKCXByaW50ZigiUGxpdGhvcyBrZXJhaW9uIHBvdSBwcmVwZWkgbmEgZWdrYXRhc3RhdGhvdW4gc3RobiBwZXJpb3hoIDI6JWxmXG4iLG1heC81MDApOwogCXN5c3RlbSgicGF1c2UiKTsKICAgIHJldHVybiAwOwp9"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define plithos_simeiwn 20
#define Xmin 719604.0 
#define Xmax 722538.0 
#define Ymin 4328469.0 
#define Ymax 4332907.0 
#define Radius 500
#define Total_Regions 2

struct Point_of_Interest
{
    char id[10];
    double x;
    double y;
};
  
struct Point_of_Interest Points[plithos_simeiwn];

double Distances [plithos_simeiwn][plithos_simeiwn];

double Average_Distances [plithos_simeiwn];

void Data_Points()
{
    int i;
	for (i=0;i<plithos_simeiwn;i++)
    {
    	printf("Dose ton kodiko tou %dou shmeiou:\n",i+1);
    	scanf("%s",Points[i].id);
    	do
    	{
    		printf("Dose th x shnistosa tou %d ou shmeiou:(719604-722538)\n",i+1);
    		scanf("%lf",&Points[i].x);
		}while(Points[i].x<Xmin||Points[i].x>Xmax);
		do
    	{
    		printf("Dose thn y shnistosa tou %d ou shmeiou:(4328469-4332907)\n",i+1);
    		scanf("%lf",&Points[i].y);
		}while(Points[i].y<Ymin||Points[i].y>Ymax);
	}
}

double Euclidean_Distance (int i, int j)
{
	return sqrt(pow(Points[i].x-Points[j].x,2)+pow(Points[i].y-Points[j].y,2));
}

void Populate_Distance_Matrix()
{
	int i,j;
	for(i=0;i<plithos_simeiwn;i++)
		for(j=0;j<plithos_simeiwn;j++)
			Distances[i][j]=Euclidean_Distance(i,j);
}

void Average_Distance_Matrix()
{
	int i,j;
	double sum;
	for(i=0;i<plithos_simeiwn;i++)
	{
		sum=0;
		for(j=0;j<plithos_simeiwn;j++)
			sum=sum+Distances[i][j];
		Average_Distances[i]=sum/(plithos_simeiwn-1);
	}
}

int main()
{
	int i,j,k1,k2,Regions[Total_Regions];
	double average,sum=0,max,average1[plithos_simeiwn],average2[plithos_simeiwn];
	
    Data_Points(); 
    printf("\n \n Data Entered \n \n");
    for (i=0; i<plithos_simeiwn;i++)
	printf("id=%s  x=%lf y=%lf \n", Points[i].id, Points[i].x, Points[i].y);
    printf("\n \n Distance Matrix \n \n");

    Populate_Distance_Matrix(); 

    for (i=0; i<plithos_simeiwn; i++)
    {
        printf("\n");
        for (j=0; j<plithos_simeiwn; j++)
            printf("%6.2lf\t", Distances[i][j]);
    }
    printf("\n \n Average Distance Matrix \n \n");

    Average_Distance_Matrix(); 

    for (i=0; i<plithos_simeiwn;i++)
		printf("id=%s  Average=%lf \n", Points[i].id, Average_Distances[i]);
	for(i=0;i<plithos_simeiwn;i++)
		sum=sum+Average_Distances[i];
	average=sum/plithos_simeiwn;
	k1=0;
	k2=0;
	for(i=0;i<plithos_simeiwn;i++)
		if(Average_Distances[i]<average)
		{
			Regions[i]=100;
			average1[k1]=Average_Distances[i];
			k1++;
		}
		else
		{
			Regions[i]=200;
			average2[k2]=Average_Distances[i];
			k2++;
		}
	max=average1[0];
	for(i=1;i<k1;i++)
		if(average1[i]>max)
			max=average1[i];
	printf("Plithos keraion pou prepei na egkatastathoun sthn perioxh 1:%lf\n",max/500);
	max=average2[0];
	for(i=1;i<k2;i++)
		if(average2[i]>max)
			max=average2[i];
	printf("Plithos keraion pou prepei na egkatastathoun sthn perioxh 2:%lf\n",max/500);
 	system("pause");
    return 0;
}