Commit a389045d by trkall

kolmas prax

parent eb621af9
fgs Loom 13 fgs Loom 13
fasgs Loom 132
gsa Lind 132
asgsa Lind 13
asf Kala 12 asf Kala 12
assdf Kala 12 assdf Kala 12
sal Putukas 835
assal Putukas 832
fgs Loom 13
fasgs Loom 132
gsa Lind 132
asgsa Lind 13
asf Kala 12
assdf Kala 12
sal Putukas 835
assal Putukas 832
...@@ -18,13 +18,12 @@ int main(void) ...@@ -18,13 +18,12 @@ int main(void)
char *str3 = "Kala"; char *str3 = "Kala";
char *str4 = "Putukas"; char *str4 = "Putukas";
Ryhm *n = malloc(100000); Ryhm *n = (Ryhm*)malloc(sizeof(Ryhm*));
F1 = fopen("F1.txt", "r"); F1 = fopen("F1.txt", "r");
while(!feof(F1) || i <= MAX) while(!feof(F1) || i <= MAX)
{ {
n = (Ryhm*)realloc(n, 35);
n = (Ryhm*)realloc(n, 350);
fscanf(F1,"%s %s %d", (n+i)->Nimi, (n+i)->Liik, &(n+i)->Vanus); fscanf(F1,"%s %s %d", (n+i)->Nimi, (n+i)->Liik, &(n+i)->Vanus);
i++; i++;
} }
......
No preview for this file type
...@@ -70,6 +70,7 @@ int t66tlus(Inimesed *Isik, Inimesed *Uus) ...@@ -70,6 +70,7 @@ int t66tlus(Inimesed *Isik, Inimesed *Uus)
{ {
strcpy((Uus+j)->nimi, (Isik+i)->nimi); strcpy((Uus+j)->nimi, (Isik+i)->nimi);
strcpy((Uus+j)->code, (Isik+i)->code);
(Uus+j)->money = (Isik+i)->money; (Uus+j)->money = (Isik+i)->money;
j++; j++;
} }
...@@ -85,7 +86,7 @@ void v2lja(Inimesed *Uus, int pikkus) ...@@ -85,7 +86,7 @@ void v2lja(Inimesed *Uus, int pikkus)
for(i=0;i<pikkus;i++) for(i=0;i<pikkus;i++)
{ {
fprintf(tulemused, "%s %lf %s\n", (Uus+i)->nimi, (Uus+i)->money, CHKCODE); fprintf(tulemused, "%s %lf %s\n", (Uus+i)->nimi, (Uus+i)->money, (Uus+i)->code);
} }
fclose(tulemused); fclose(tulemused);
} }
No preview for this file type
12.87 14.78
-45.78 48.14
-87.41 28.47
42.41 -9.47
-1.78 -4.78
17.11 -41.72
-88.11 58.41
42.41 9.26
5.88 4.18
-14.21 44.12
12.87 14.78
-45.78 48.14
-87.41 28.47
42.41 -9.47
-1.78 -4.78
17.11 -41.72
-88.11 58.41
42.41 9.26
5.88 4.18
-14.21 44.12
42.87 11.38
-65.78 43.13
-17.41 24.97
44.41 -21.47
-41.78 -55.98
17.11 -1.72
-18.11 8.41
43.41 1.26
6.78 2.18
-13.21 42.12
42.87 11.38
-65.78 43.13
-17.41 24.97
44.41 -21.47
-41.78 -55.98
17.11 -1.72
-18.11 8.41
43.41 1.26
6.78 2.18
-13.21 42.12
12.14 24.47
78.42 -12.45
11.11 65.26
79.41 -12.47
97.41 12.56
-33.48 41.62
51.94 12.46
35.63 23.12
-96.74 13.64
89.12 -35.78
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
//#include <math.h>
typedef struct{
float x;
float y;
}Co;
int MAX = 10;
int sisse(Co X[], int);
float *pind(Co A[], Co B[], Co C[]);
int chkFile(FILE *andmed);
int main(void)
{
Co A[10];
Co B[10];
Co C[10];
FILE *S;
int i = 0;
float *pindala;
int chk;
chk += sisse(A, 1);
chk += sisse(B, 2);
chk += sisse(C, 3);
if (chk != 0)
{
return 0;
}
pindala = pind(A, B, C);
return 0;
}
int sisse(Co X[], int param)
{
FILE *andmed;
int chk = 0;
int i = 0;
if (param == 1)
{
andmed = fopen("aAndmed.txt", "r");
chk += chkFile(andmed);
} else if (param == 2)
{
andmed = fopen("bAndmed.txt", "r");
chk += chkFile(andmed);
} else
{
andmed = fopen("cAndmed.txt", "r");
chk += chkFile(andmed);
}
if (chk == 0)
{
printf("A File is missing!");
return 1;
}
while(i<MAX)
{
fscanf(andmed, "%lf %lf", &X[i].x, &X[i].y);
printf("%lf\n", X[i].x);
i++;
}
fclose(andmed);
return 0;
}
float *pind(Co A[], Co B[], Co C[])
{
int i = 0;
float *S = malloc(1000);
for(i=0;i<MAX;i++)
{
*(S+i) = abs((A[i].x * (B[i].y - C[i].y) + B[i].x * (C[i].y - A[i].y) +
C[i].x * (A[i].y - B[i].y)));
}
return S;
}
int chkFile(FILE *andmed)
{
if(andmed == NULL)
{
return 0;
}
return 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment