Advertisement
Guest User

Untitled

a guest
May 27th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. int sati_presmetka(entry_time *sati, int size)
  2. {
  3.    
  4.     int i;
  5.     int vkupno = 0;
  6.     int temp, temp1 = 0;
  7.    
  8.     for(i = 0;i < size;i = i + 2) {
  9.        
  10.        temp = (sati[i + 1].hour * 60) + sati[i + 1].minute;
  11.        std::cout<<temp<<std::endl;
  12.        temp1 = (sati[i].hour * 60) + sati[i].minute;  
  13.        std::cout<<temp1<<std::endl;
  14.        vkupno = vkupno + (temp - temp1);        
  15.     }  
  16.     return vkupno;
  17. } // go vraka vremeto vo minuti
  18.  
  19. posle vo ova funkcija mozi da se iskoristi na ovaj nacin :
  20.  
  21. void den_pregled(const char *file)
  22. {    
  23.     struct entry_time *struct_output; // pointer kon niza vo koja ke se cuvat site vreminja
  24.     int lines = count_lines(file);
  25.     int i = 0;
  26.    
  27.     struct_output = return_entries(file); // dinamicki ja popolnuva nizata so posoceniot fajl, treba da se napraj delete[]
  28.    
  29.     for(i = 0;i < lines;i++) {
  30.        
  31.        if(i == 0 || i % 2 == 0) {
  32.            
  33.             std::cout<<"Vlegol:"<<std::endl;
  34.            
  35.        }
  36.        else {
  37.             std::cout<<std::endl<<"Izlegol:"<<std::endl;
  38.        }  
  39.        std::cout<<"Sat:"<<struct_output[i].hour<<std::endl;  
  40.        std::cout<<"Minuta:"<<struct_output[i].minute<<std::endl<<std::endl;
  41.        
  42.     }
  43.    
  44.     std::cout<<"\n satite se : "<<sati_presmetka(struct_output, lines); // i vo MINUTI gi vadi satite ovde, sega treba nekako da
  45.                                     // se pretvorat vo sati
  46.    
  47.     std::cin.get();
  48.    
  49.     delete[] struct_output; //se deletira oti drzi memorija
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement