IvoSilva

[PROG1] Mini-Teste Exemplo #1 | Exercício 2.2

Nov 19th, 2011
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. void converte(int tipo , int *vSegs , int *mnts , int *segs)
  3. {
  4.     if (!tipo)
  5.     {
  6.         *mnts = *vSegs / 60 ;
  7.         *segs = *vSegs % 60 ;
  8.     }
  9.     else *vSegs = *mnts * 60 + *segs ;
  10. }
  11. int main()
  12. {
  13.     int tipo , vSegs , mnts , segs ;
  14.     printf ("Escolha o tipo de dados que vai introduzir : ") ;
  15.     scanf ("%d" , &tipo) ;
  16.     if (!tipo)
  17.     {
  18.         printf ("Introduza o valor total de segundos : ") ;
  19.         scanf ("%d" , &vSegs) ;
  20.     }
  21.     else
  22.     {
  23.         printf ("Introduza o valor de minutos e segundos : ") ;
  24.         scanf ("%d %d" , &mnts , &segs) ;
  25.     }
  26.     converte(tipo , &vSegs , &mnts , &segs) ;
  27.     if (!tipo) printf ("Valor convertido para minutos e segundos : %d:%d\n" , mnts , segs) ;
  28.     else printf ("Valor convertido para segundos : %d\n" , vSegs) ;
  29.     return 0 ;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment