Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <conio.h>
- int getline(char s[], int n)
- {
- int c, i;
- for (i = 0; i<n && (c = getchar()) != EOF&&c != '\n'; ++i)
- s[i] = c;
- s[i] = '\0';
- while (c != EOF&&c != '\n') c = getchar();
- return(i);
- }
- typedef struct percek
- {
- int perc;
- int ora;
- int min;
- }PK;
- int main()
- {
- char szam [5];
- int i=0,ok=0,j=0,k=0;
- FILE *fp;
- PK *tomb;
- fp=fopen("percek.txt","r");
- while(!feof(fp))
- {fscanf(fp,"%d\n",&ok);
- k++;}
- fclose(fp);
- tomb=(PK*)malloc(sizeof(PK)*k);
- i=0;
- fp=fopen("percek.txt","r");
- while(!feof(fp))
- {
- fscanf(fp,"%d\n",&tomb[i].perc);
- if(tomb[i].perc<0 ||tomb[i].perc>1439)
- printf("%d hibas perc adat adat\n\n\n",tomb[i].perc);
- else i++;
- }
- fclose(fp);
- for(j=0;j<i;j++)
- {
- tomb[j].ora=(tomb[j].perc/60);
- tomb[j].min=(tomb[j].perc-(tomb[j].perc/60)*60);
- if(tomb[j].min==0)
- printf("%d perc\t:%d:00\n",tomb[j].perc,(tomb[j].ora));
- else
- printf("%d perc\t:%d:%d\n",tomb[j].perc,(tomb[j].ora),tomb[j].min);
- }
- free(tomb);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement