Advertisement
Guest User

Untitled

a guest
May 25th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <conio.h>
  5. int getline(char s[], int n)
  6. {
  7.     int c, i;
  8.     for (i = 0; i<n && (c = getchar()) != EOF&&c != '\n'; ++i)
  9.         s[i] = c;
  10.     s[i] = '\0';
  11.     while (c != EOF&&c != '\n') c = getchar();
  12.     return(i);
  13. }
  14. typedef struct percek
  15. {
  16.  
  17. int perc;
  18. int ora;
  19. int min;
  20. }PK;
  21.  
  22. int main()
  23. {
  24.     char szam [5];
  25.     int i=0,ok=0,j=0,k=0;
  26.     FILE *fp;
  27.     PK *tomb;
  28.    
  29.     fp=fopen("percek.txt","r");
  30.         while(!feof(fp))
  31.             {fscanf(fp,"%d\n",&ok);
  32.         k++;}
  33.         fclose(fp);
  34.  
  35. tomb=(PK*)malloc(sizeof(PK)*k);
  36. i=0;
  37. fp=fopen("percek.txt","r");
  38. while(!feof(fp))
  39. {
  40.     fscanf(fp,"%d\n",&tomb[i].perc);
  41.     if(tomb[i].perc<0 ||tomb[i].perc>1439)
  42.     printf("%d hibas perc adat adat\n\n\n",tomb[i].perc);
  43.     else i++;
  44. }
  45. fclose(fp);
  46. for(j=0;j<i;j++)
  47. {
  48.     tomb[j].ora=(tomb[j].perc/60);
  49.     tomb[j].min=(tomb[j].perc-(tomb[j].perc/60)*60);
  50.     if(tomb[j].min==0)
  51.     printf("%d perc\t:%d:00\n",tomb[j].perc,(tomb[j].ora));
  52.     else
  53.     printf("%d perc\t:%d:%d\n",tomb[j].perc,(tomb[j].ora),tomb[j].min);
  54. }
  55. free(tomb);
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement