Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 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. int polje[30];
  32. kripto tmp;
  33.  
  34. FILE *fo=NULL;
  35. fo=fopen("creepto.val","rb");
  36. if(fo == NULL) exit(1);
  37.  
  38. scanf("%s",unos);
  39. l=strlen(unos);
  40.  
  41. while(!feof(fo)){
  42. fread(&tmp,sizeof(kripto),1,fo);
  43. j=0;
  44.  
  45. for (i=0;i<l;i++){
  46. char *slovo=strchr(tmp.kod,unos[i]);
  47. if(slovo != NULL){
  48. j++;
  49.  
  50. if(j==l){
  51.  
  52. b=(tmp.sat*3600)+(tmp.min*60)+tmp.sec;
  53.  
  54. strcpy(lista1[a].kod1,tmp.kod);
  55.  
  56. lista1[a].sat1=tmp.sat;
  57.  
  58. lista1[a].min1=tmp.min;
  59. lista1[a].sec1=tmp.sec;
  60. lista1[a].zbroj1=b;
  61. polje[a]=b;
  62. lista1[a].zbroj1=b;
  63. a++;
  64.  
  65. }
  66. }
  67. }
  68. }
  69. fclose(fo);
  70.  
  71. int temp;
  72. int m;
  73.  
  74.  
  75.  
  76. for(m=0;m<(a-1);m++){
  77. for (d=0;d<(a-m-1);d++){
  78. if (polje[d]>polje[d+1]){
  79. temp=polje[d];
  80. polje[d]=polje[d+1];
  81. polje[d+1]=temp;
  82. }
  83.  
  84. }
  85. }
  86. for(m=0;m<a;m++){
  87. for (d=0;d<a;d++){
  88. if (polje[m]==lista1[d].zbroj1){
  89. printf("%s@%02d:%02d:%02d\n", lista1[d].kod1, lista1[d].sat1, lista1[d].min1, lista1[d].sec1);
  90. }
  91. }
  92. }
  93.  
  94.  
  95.  
  96.  
  97. return 0;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement