Commit fd1ae2a3 by trkall

grinder yl

parent d674cadb
M Aivar 16 180 83.1 blond
M Juhan 21 175 71.3 ginger
F Mari 15 159 57.5 blond
M Georg 24 197 91.1 brynett
F Alma 67 171 92.4 ginger
M Urmas 29 176 164.8 kiilas
M Rivo 13 164 62.9 brynett
F Ina 17 188 76.2 brynett
M Mehis 47 178 99.4 kiilas
M Madis 32 185 106.6 ginger
F Julia 24 174 67.7 blond
F Marta 35 161 84.4 kiilas
M Misha 23 166 69.7 brynett
M Valdur 57 174 88.4 blond
F Tiiu 44 179 103.4 kiilas
M Aivar 16 180 83.1 blond
M Juhan 21 175 71.3 ginger
F Mari 15 159 57.5 blond
M Georg 24 197 91.1 brynett
F Alma 67 171 92.4 ginger
M Urmas 29 176 164.8 kiilas
M Rivo 13 164 62.9 brynett
F Ina 17 188 76.2 brynett
M Mehis 47 178 99.4 kiilas
M Madis 32 185 106.6 ginger
F Julia 24 174 67.7 blond
F Marta 35 161 84.4 kiilas
M Misha 23 166 69.7 brynett
M Valdur 57 174 88.4 blond
F Tiiu 44 179 103.4 kiilas
#include <stdio.h>
#include <stdlib.h>
struct node
{
char sugu;
char nimi[20];
int vanus;
int pikkus;
double kaal;
char juuksed[20];
double BMI;
struct node *ptr;
}*top, *temp, *top1;
void failist_sisse(FILE* F1);
void display();
int chkFile(FILE* F1);
int main(void)
{
FILE* F1;
char soolineeelistus;
int ylempiir;
int alampiir;
double soovitudkehamassiindeks;
int i = 0;
top = NULL;
F1 = fopen("andmed.txt", "r");
int chk = chkFile(F1);
while(i<15)
{
failist_sisse(F1);
i++;
}
fclose(F1);
///
display();
///
return 0;
}
void failist_sisse( FILE* F1)
{
if (top == NULL)
{
top = (struct node *)malloc(sizeof(struct node));
top->ptr = NULL;
fscanf(F1, "%c %s %d %d %lf %s", top->sugu, top->nimi, &top->vanus, &top->pikkus, &top->kaal, top->juuksed);
}
else
{
temp =(struct node *)malloc(sizeof(struct node));
temp->ptr = top;
fscanf(F1, "%c %s %d %d %lf %s", temp->sugu, temp->nimi, &temp->vanus, &temp->pikkus, &temp->kaal, temp->juuksed);
top = temp;
}
}
void display()
{
top1 = top;
if (top1 == NULL)
{
printf("Stack is empty");
return;
}
while (top1 != NULL)
{
printf("%c %s %d %d %0.2f %s\n", top1->sugu, top1->nimi, top1->vanus, top1->pikkus, top1->kaal, top1->juuksed);
top1 = top1->ptr;
}
}
int chkFile(FILE* file)
{
if (file == NULL)
{
return 1;
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node
{
char sugu;
char nimi[20];
int vanus;
int pikkus;
double kaal;
char juuksed[20];
double BMI;
struct node *ptr;
}*top, *temp, *top1;
void failist_sisse(char, char[], int, int, double, char[]);
void display();
int count = 0;
int main(void)
{
FILE* F1;
char soolineeelistus;
int ylempiir;
int alampiir;
double soovitudkehamassiindeks;
int i = 0;
char a;
char b[20];
int c, d;
double e;
char f[20];
top = NULL;
F1 = fopen("andmed.txt", "r");
while(!feof(F1) && i<15)
{
fscanf(F1, "%c %s %d %d %lf %s", a, b, &c, &d, &e, f);
failist_sisse(a, b, c, d, e, f);
i++;
}
fclose(F1);
///
display();
///
return 0;
}
void failist_sisse(char sugu, char nimi[20], int vanus, int pikkus, double kaal, char juuksed[20] )
{
if (top == NULL)
{
top = (struct node *)malloc(sizeof(struct node));
top->ptr = NULL;
top->sugu = sugu;
///top->nimi = nimi;
strcpy(top->nimi, nimi);
top->vanus = vanus;
top->pikkus = pikkus;
top->kaal = kaal;
///top->juuksed = juuksed;
strcpy(top->juuksed, juuksed);
}
else
{
temp =(struct node *)malloc(sizeof(struct node));
temp->ptr = top;
temp->sugu = sugu;
///top->nimi = nimi;
strcpy(temp->nimi, nimi);
temp->vanus = vanus;
temp->pikkus = pikkus;
temp->kaal = kaal;
///top->juuksed = juuksed;
strcpy(temp->juuksed, juuksed);
top = temp;
}
count++;
}
void display()
{
top1 = top;
if (top1 == NULL)
{
printf("Stack is empty");
return;
}
while (top1 != NULL)
{
printf("%c %s %d %d %0.2f %s\n", top1->sugu, top1->nimi, top1->vanus, top1->pikkus, top1->kaal, top1->juuksed);
top1 = top1->ptr;
}
}
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