Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------------------------------------------------------
- // temp_appel = (nbr_min*60) + nbr_sec //(en secondes)
- // nbr_unit = temp_appel/unit //(unit = 20 sec)
- // cout_3min = 12,6 DH //(cout_3min = 180/20 * 1,40 = 9*1,40 = 12,6)
- // cout_next = nbr_unit * prix_unit + rest_sec //(rest_sec = 0 si: temp_appel%unit=0 , sinon: rest_sec = 1,20)
- // cout_appel = cout_3min + cout_next
- //---------------------------------------------------------------------------------------------------------------------------
- #include<stdio.h>
- int main()
- {
- int nbr_min, nbr_sec, temp_appel, unit=20 ;
- float nbr_unit, prix_unit, cout_min, rest_sec, cout_appel ;
- start:
- printf("===========================================================\n");
- printf("Calcul du cout d’une communication par appel telephonique\n");
- printf("===========================================================\n");
- printf("\nEntrez la duree de l'appel (en minutes et secondes):\n");
- printf("___________________________________________________________\n");
- printf("\n\tMinutes: ");
- scanf("%d", &nbr_min);
- printf("\tSecondes: ");
- scanf("%d", &nbr_sec);
- //---------------------------------------------------------------------------------------------------------------------------
- //---------------------------------------------------------------------------------------------------------------------------
- temp_appel = (nbr_min*60)+nbr_sec ;
- nbr_unit = temp_appel/unit ;
- rest_sec = temp_appel%unit ;
- cout_min = (60/unit)*1.40 ;
- //---------------------------------------------------------------------------------------------------------------------------
- if (temp_appel == 0) { cout_appel = 0; } else
- //---------------------------------------------------------------------------------------------------------------------------
- if (temp_appel <= 60) {
- cout_appel = cout_min ;
- } else if (temp_appel <= 180) {
- prix_unit = 1.40 ;
- if (rest_sec != 0) { rest_sec = prix_unit; }
- cout_appel = nbr_unit*prix_unit + rest_sec ;
- } else {
- prix_unit = 1.20 ;
- temp_appel = temp_appel - 180 ;
- nbr_unit = temp_appel/unit ;
- rest_sec = temp_appel%unit ;
- if (rest_sec != 0) { rest_sec = prix_unit; };
- cout_appel = nbr_unit*prix_unit + rest_sec ;
- cout_appel = cout_appel + 3*cout_min ;
- }
- //---------------------------------------------------------------------------------------------------------------------------
- printf("___________________________________________________________\n");
- printf("\n\tLe cout de l'appel est: %.2f DH\n", cout_appel);
- printf("___________________________________________________________\n");
- system("pause>nul");
- system("cls");
- goto start;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement