Advertisement
Guest User

ines10

a guest
Jan 21st, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. typedef struct{
  6.     char kod[20+1];
  7.     int iznos;
  8.     int dan;
  9.     int mjesec;
  10.     int godina;
  11.     int sat;
  12.     int min;
  13.     int sec;
  14. }kripto;
  15.  
  16. struct dozvola{
  17.  
  18.     char kod1[20+1];
  19.     int sat1;
  20.     int min1;
  21.     int sec1;
  22.     int zbroj1;
  23.  
  24. }lista1[30];
  25.  
  26.  
  27. int main()
  28. {
  29.     char unos[5]={0};
  30.     int i,j=0,l,a=0,d,b;
  31.     kripto tmp;
  32.  
  33.     FILE *fo=NULL;
  34.     fo=fopen("creepto.val","rb");
  35.     if(fo == NULL) exit(1);
  36.  
  37.     scanf("%s",unos);
  38.     l=strlen(unos);
  39.  
  40.     while(!feof(fo)){
  41.     fread(&tmp,sizeof(kripto),1,fo);
  42.     j=0;
  43.  
  44.     for (i=0;i<l;i++){
  45.         char *slovo=strchr(tmp.kod,unos[i]);
  46.         if(slovo != NULL){
  47.         j++;
  48.  
  49.         if(j==l){
  50.  
  51.         b=(tmp.sat*3600)+(tmp.min*60)+tmp.sec;
  52.  
  53.         strcpy(lista1[a].kod1,tmp.kod);
  54.  
  55.         lista1[a].sat1=tmp.sat;
  56.  
  57.         lista1[a].min1=tmp.min;
  58.         lista1[a].sec1=tmp.sec;
  59.         lista1[a].zbroj1=b;
  60.  
  61.         a++;
  62.  
  63.         }
  64.         }
  65.     }
  66.     }
  67.  
  68.     int temp;
  69.     int m;
  70.  
  71.  
  72.         for(m=0;m<(a-1);m++){
  73.             for (d=0;d<(a-m-1);d++){
  74.                 if (lista1[d].zbroj1>lista1[d+1].zbroj1){
  75.                     temp=lista1[d].zbroj1;
  76.                     lista1[d].zbroj1=lista1[d+1].zbroj1;
  77.                     lista1[d+1].zbroj1=temp;
  78.                 }
  79.  
  80.             }
  81.         }
  82.         for(m=0;m<a;m++){
  83.             for (d=0;d<a;d++){
  84.                 if (lista1[m].zbroj1==lista1[d].zbroj1){
  85.                 printf("%s@%02d:%02d:%02d\n", lista1[d].kod1, lista1[d].sat1, lista1[d].min1, lista1[d].sec1);
  86.                 }
  87.         }
  88.         }
  89.  
  90.  fclose(fo);
  91.  
  92.  
  93. return 0;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement