Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define ORE 3600
  4. #define MINUTI 60
  5.  
  6. void calcolaTempo(int secondi){
  7.     int ore,minuti;
  8.     int rest;
  9.    
  10.     ore=secondi/ORE;
  11.     rest=secondi%ORE;
  12.     minuti=rest/MINUTI;
  13.     if( (rest%MINUTI) != 0)
  14.         rest=rest%MINUTI;
  15.     else
  16.         rest=0;
  17.     printf("Il parametro iniziali di: %d, corrisponde a: %d ore, %d minuti e %d secondi\n",secondi,ore,minuti,(int)rest);
  18.  
  19. }
  20.  
  21. int main(int argc, char* argv[]){
  22.     if(argc != 2){
  23.         printf("Hai immesso un numero di parametri non valido\n");
  24.         exit(-1);
  25.     }
  26.  
  27.     int tInput= atoi(argv[1]);
  28.     calcolaTempo(tInput);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement