|
|
| Ligne 1 : |
Ligne 1 : |
| − | <source lang=c> | + | [[Cours:TDs_1103|{{Rouge|<big>'''Retour à la liste des Tds'''</big>}}]] |
| − | #include <iostream>
| |
| − | using namespace std;
| |
| | | | |
| − | int main()
| + | [[Cours:TdCPPCorrection|{{Vert|<big>'''Éléments de correction'''</big>}}]] |
| − | { | |
| − | float prix;
| |
| − | float total=0;
| |
| − | float r=0;
| |
| − | float prixMin=999999,prixMax=0;
| |
| − | do
| |
| − | {
| |
| − | cout << "Saisir prix" << endl;
| |
| − | cin >> prix;
| |
| − | if (prix>0)
| |
| − | {
| |
| − | if (prix>prixMax) prixMax=prix;
| |
| − | if (prix<prixMin) prixMin=prix;
| |
| − | }
| |
| − | total=prix+total;
| |
| − | } while(prix!=0);
| |
| − | // Calcul de la remise
| |
| − | if (total>999) {r=total*0.3;}
| |
| − | else if (total>499) {r=total*0.2;}
| |
| − | else if (total>99) {r=total*0.1;}
| |
| − | else {r=0;}
| |
| − | //Affichage
| |
| − | cout << "Prix total avant réduction:" << total <<endl;
| |
| − | cout << " Montant de la réduction:" << r <<endl;
| |
| − | cout << " A payer :" << total-r<<endl;
| |
| − | return 0;
| |
| − | }
| |
| − | </source>
| |
Version du 22 octobre 2016 à 13:56