Commit d674cadb by trkall

Merge branch 'master' of http://gitlab.pld.ttu.ee/trkall/iag0582

lol
parents 541678e5 163c1f75
fgs Loom 13
fasgs Loom 132
gsa Lind 132
asgsa Lind 13
asf Kala 12
assdf Kala 12
sal Putukas 835
assal Putukas 832
...@@ -23,7 +23,11 @@ int main(void) ...@@ -23,7 +23,11 @@ int main(void)
Ryhm *n = (Ryhm*)malloc(sizeof(Ryhm*)); Ryhm *n = (Ryhm*)malloc(sizeof(Ryhm*));
F1 = fopen("F1.txt", "r"); F1 = fopen("F1.txt", "r");
if (chkFile(F1) == 0)
{
printf("Andmete fail puudub, sulgen programmi!\n");
return 0;
}
while(!feof(F1) || i <= MAX) while(!feof(F1) || i <= MAX)
{ {
n = (Ryhm*)realloc(n, 35); n = (Ryhm*)realloc(n, 35);
......
1.12 1.12
4.78 4.78
5.57 5.57
8.12 8.12
3.14 3.14
2.28 2.28
1.11 1.11
69.69 69.69
12.41 12.41
4.20 4.20
int FileSisse(double* Aarr, FILE *sisse)
void FileSisse(double* Aarr, FILE *sisse)
{ {
int i = 0; int i = 0;
int y; double y;
while(fscanf(sisse, "%d", &y) != EOF) while( !feof(sisse))
{ {
fscanf(sisse, "%lf", &y);
*(Aarr+i) = y; *(Aarr+i) = y;
i++; i++;
} }
return i-1;
} }
void t66tlus(double *Aarr, double *Barr, int X) void t66tlus(double* Aarr, double* Barr, int X, int pikkus)
{ {
int i; int i;
int j = 0; int j = 0;
int k; int k;
for(i=0;j<15;i++)
for(i=0;j<pikkus;i++)
{ {
*(Barr+i) = 0; *(Barr+i) = 0;
if(i !=0) if(i !=0)
...@@ -30,6 +32,7 @@ void t66tlus(double *Aarr, double *Barr, int X) ...@@ -30,6 +32,7 @@ void t66tlus(double *Aarr, double *Barr, int X)
*(Barr+i) /= pov(X, i); *(Barr+i) /= pov(X, i);
} }
} }
} }
int pov(int a, int b) int pov(int a, int b)
...@@ -39,4 +42,5 @@ int pov(int a, int b) ...@@ -39,4 +42,5 @@ int pov(int a, int b)
{ {
a*=a; a*=a;
} }
return a;
} }
#include <stdio.h> #include <stdio.h>
#include "functions.c" #include "functions.c"
int FileSisse(double* , FILE *sisse);
void t66tlus(double*, double*, int , int );
int pov(int , int );
int main(void) int main(void)
{ {
FILE *sisse; FILE *sisse;
double *Aarr, *Barr; double* Aarr;
int X, i; double* Barr;
int X, i, pikkus;
sisse = fopen("andmed.txt", "r"); sisse = fopen("andmed.txt", "r");
FileSisse(Aarr, sisse);
pikkus = FileSisse(Aarr, sisse);
fclose(sisse);
printf("Sisestage X:\n"); printf("Sisestage X:\n");
scanf("%d", &X); scanf("%d", &X);
t66tlus(Aarr, Barr, X); t66tlus(Aarr, Barr, X, pikkus);
for(i=0;i<15;i++) for(i=0;i<pikkus;i++)
{ {
printf("%0.2f", *(Barr+i)); printf("%0.2f", *(Barr+i));
} }
......
No preview for this file type
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