Commit afe04b92 by videid

hw2

parent 673ce6bd
9
Keskmine 9.98
Ronimine 3.10
Pikk 17.52
Lyhike 3.73
Rada2 6.19
Mets 4.92
Soo3 5.05
Lyhike2 3.81
Varemed 5.99
1
\ No newline at end of file
#include <time.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h>
typedef char string[31];
void size(int* rows,int* columns); int main(){
void fill(int rows,int columns); float tps;
int i;
int j=0;
int h = 0;
int f = 0;
int k = 0;
int g = 0;
char *b ;
char *c ;
string array[30] = {0};
char *name[15];
char *length[15];
FILE *my;
my = fopen("C:\\Users\\vggre\\Documents\\GitHub\\iax5832\\iax0583\\homework2\\081.txt","r");
for(i = 0; i < 30; i++){
fscanf(my, "%s", array[i]);
printf("%s\n",array[i]);
}
int main(void){ fclose(my);
int rows ;
int columns ;
size(&rows,&columns);
fill(rows,columns);
while (*array[h] != 0 ){
h=h+1;
}
printf("%d\n",h);
for(j = 1; j < h-1; j=j+2){
printf(" trail %d %s\n",((j+1)/2),array[j]);
}
return 0 ; for(i = 1; i < h-1; i++){
}
void size(int *rows,int *columns){
*rows = 0; if (i%2){
*columns =0 ; b = array[i];
while(*rows<= 0) { name[i/2] = b;
printf("enter number of rows\n"); printf("%s\n",name[i/2]);
scanf("%d", rows); }
else {
c = array[i];
length[(i-1)/2] = c;
printf("%s\n",length[(i-1)/2]);
} }
while(*columns <= 0) {
printf("enter number of columns\n");
scanf("%d", columns);
} }
printf("%d rows %d columns \n",*rows,*columns);
} printf("\n\n\n\n\n\n\n");
void fill(int rows,int columns){
int h; char *temp;
int i; for (k = 0; k < (h/2) -1; k++){
int j;
int myArray[rows][columns]; for (g = 0;g < (h/2)-2-k; g++ ){
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){ if (*length[g] > *length[g+1]){
printf("enter number \n"); temp = length[g+1];
scanf("%d", &h); length[g+1] = length[g];
myArray[i][j] = h; length[g] = temp;
temp = name[g+1];
name[g+1] = name[g];
name[g] = temp;
}
} }
}
for(i = 0; i < (h/2) -1; i++){
printf("%s ",name[i]);
printf("%s km\n",length[i]);
} }
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){ printf("enter time in minutes\n");
printf("%d",myArray[i][j]); scanf("%f", &tps);
for(i = 0; i < (h/2) -1; i++){
char *y ;
y = length[i] ;
float time;
time = atof(y)/0.083; // this is not precise beyond minutes because that's not relevant for a hike
if (time<= tps){
printf ("the %s hike is doable is this time\n",name[i]);
}
} }
printf("\n");
}
return 0;
} }
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