Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct{
- char kod[20+1];
- int iznos;
- int dan;
- int mjesec;
- int godina;
- int sat;
- int min;
- int sec;
- }lista;
- struct dozvola{
- char kod1[20+1];
- int sat1;
- int min1;
- int sec1;
- int broj;
- }lista1[30];
- int main()
- {
- char usporedba[5]={0};
- int i,j,l,a,swap,b;
- int niz[30];
- lista r;
- scanf("%s",usporedba);
- l=strlen(usporedba);
- FILE *ulaz=NULL;
- ulaz=fopen("creepto.val","rb");
- if(ulaz == NULL){
- printf("Neuspjesno otvaranje datoteke!");
- exit(1);
- }
- a=0;
- while(!feof(ulaz)){
- fread(&r,sizeof(lista),1,ulaz);
- j=0;
- for (i=0;i<l;i++){
- char *slovo=strchr(r.kod,usporedba[i]);
- if(slovo != NULL){
- j++;
- if(j==l){
- b=(r.sat*3600)+(r.min*60)+r.sec;
- strcpy(lista1[a].kod1,r.kod);
- lista1[a].sat1=r.sat;
- lista1[a].min1=r.min;
- lista1[a].sec1=r.sec;
- lista1[a].broj=b;
- niz[a]=b;
- a++;
- }
- }
- }
- }
- fclose(ulaz);
- for (i=0;i<(a-1);i++){
- for(j=0;j<(a-i-1);j++){
- if (niz[j]>niz[j+1]){
- swap=niz[j];
- niz[j]=niz[j+1];
- niz[j+1]=swap;
- }
- }
- }
- for (i=0;i<a;i++){
- for (j=0;j<a;j++){
- if (niz[i]==lista1[j].broj){
- printf("%s@",lista1[j].kod1);
- if (lista1[j].sat1<10){
- printf("%02d:", lista1[j].sat1);
- }else{
- printf("%d:", lista1[j].sat1);
- }
- if (lista1[j].min1<10){
- printf("%02d:", lista1[j].min1);
- }else{
- printf("%d:", lista1[j].min1);
- }
- if (lista1[j].sec1<10){
- printf("%02d", lista1[j].sec1);
- }else{
- printf("%d", lista1[j].sec1);
- }
- }
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement