Administration

Vous êtes ici : Accueil » programmation » Algorithme CONVERTIR qui transforme une durée exprimée en Seconde, en heures, minutes, et seconde

Algorithme CONVERTIR qui transforme une durée exprimée en Seconde, en heures, minutes, et seconde

 

 

Algorithme CONVERTIR qui transforme une durée exprimée en  Seconde, en heures, minutes, et seconde

 

 

 

#include<stdio.h>

    #include<stdlib.h>

   

    int heure,duree,minute,j,s,H,M,S,s1,s2,s3,J,s4,t,s5,s6,mo,an,mois,duree1,mo1,jou,sem;

    

   

    /*Ecrire un algorithme CONVERTIR qui transforme une durée exprimée en

    seconde(Duree),en heures(HEURES),minutes(MINUTES),et seconde ( SECONDES)

   

    exemple

    soit Duree egal à 21556 s. On doit convertir cette en HEURES,MINUTES et SECONDES.

    21556 s =5H 59 MIN 16 S.Donc la varrible HEURE on aura 5, dans MINUTE on aura  59 et

    et dans SECONDE on aura 16

   

    {

      Algo CONVERSION

     

      var

         duree,heure,munite:entier

      debut

           afficher duree

           saisir duree

           heure<==div 3600

           duree <==duree mod 3600

           munite<==duree div 60

           duree <== duree mod 60

           afficher heure"h",munite"mn",duree"s"

               

      fin  */                 

         

        

  main()

         

         

  {

        printf("Veuillez inserer la duree en mois s'il vous plait ");

                  printf(" ");

                   scanf("%d",&mois);

                    printf(" ");

                        

                     printf("Veuillez inserer la duree en semaine s'il vous plait ");               

                      printf(" ");

                       scanf("%d",&t);

                        printf(" ");

                       

                         printf("Veuillez inserer la duree en jour s'il vous plait ");               

                          printf(" ");

                            scanf("%d",&J);

                           

                             printf(" ");

                               printf("Veuillez inserer la duree en heure s'il vous plait ");                

                                printf(" ");  

                                 scanf("%d",&H);

                                  printf(" ");

                                   

                                    printf("Veuillez inserer la duree en minute s'il vous plait ");

                                    printf(" ");

                                     scanf("%d",&M);

                                      printf(" ");

                

                                        printf("Veuillez inserer la duree en seconde s'il vous plait ");               

                                          printf(" ");

                                           scanf("%d",&S);

                                             printf(" ");

                                              /*les formules*/               

                                              s1=H*3600;

                                               s2=M*60;

                                                 s3=S*1;

                                                  s4=J*86400;

                                                   s5=t*604800;

                                                    s6=mois*2592000;

                                                     duree=s1+s2+s3+s4+s5;

                                                       duree1=duree+s6;

                                                         mo=duree1/2592000;

                                                           jou=duree1/86400;

                                                            sem=duree1/604800;

         

         

         

         

                       

                                         printf("Cette duree correspond a un nombre total de %d secondes ",duree1);

                

                                           if(duree<86400)

                                            {

                                                heure=duree/3600;

                                                  duree=duree%3600;

                                                   minute=duree/60;

                                                    duree=duree%60;

                                            }   

                            

                                

          

                

              

         

                

                      

                                   

                                              printf(" ");

                                                if(duree>=86400)

                

                                                 {

                  

                                                  

                                                   j=duree/86400;

                                                    

                                                         duree=duree%86400;

                                                          heure=duree/3600;

                                                             duree=duree%3600;

                                                               minute=duree/60;

                                                                duree=duree%60;

                                                                   printf(" ");

                                                 }

                  

                  

                  

                  

                                         if( j>=7)

                                            {

                                               s=j/7;

                                                 j=j%7;

                                                    

                                                     printf(" ");

                                                     

                                             }

                                            

                 

                                           

                    

                                                 printf(" ");

                                                  printf("Cette duree en seconde correspond a %d mois",mo);

                                                   printf(" ");

                                                  

                                                       

                                                        if(s>=4)

                                                         {

                                                           mo1=s/4;

                                                            s=s%4;

                                                         }

                 

                                     printf("Cette duree en seconde corespond a %d ", jou);

                                      printf(" jour(s)");

                                       printf(" ");

                                         printf("Cette duree en seconde correspond a %d semaine(s)",sem);

                                          if(mo>=12)

                                           {

                                             an=mo/12;

                                               mo=mo%12;

                                                printf(" ");

                                                 printf("Cette duree en seconde correspond a %d annee(s) ",an);

                                                  printf(" ");

                                                 

                                           } 

                

                

                                   printf(" ");

                                    printf("cette duree correspond a : %d ",an);

                                       printf("an(s) %d",mo);

                                         printf(" mois %d",s);

                                          printf(" semaine(s) %d ",j);

                                             printf("jour(s)");

                                                printf(" %d ",heure);

                                                  printf("h %d ",minute);

                                                       printf("mn %d ",duree);

                                                         printf(" s ");

                                                           printf(" ");

                                                             system("pause");

                

                 

                

                

            

          

                                                            

               

  }

           

    


Date de publication:   29/11/2014


Régime Montignac

Le régime Montignac a été développé par l'homme d'affaires du même nom. On appelle souvent ce régime, le « régime des managers ».

Page précédent 113 115 116 117 118 119 120 121 122 Page suivante

Laisser un commentaire





bkpux035


zack77 Jeudi 16 Août 2018

Aucun commentaire pour le moment concernant le sujet « Algorithme CONVERTIR qui transforme une durée exprimée en Seconde, en heures, minutes, et seconde »!