Train of thought: only 8 This number special, 3+5>4+4, other as long as except 5 take surplus can.
I stole a lazy, directly listed if ...
#include <iostream>using namespacestd;voidMain () {intN; inti; cout<<"Please enter this number:"<<Endl; CIN>>N; I= n/5; if(n<5) { if(n==1) cout<<"Lowest Price is $8"<<Endl; if(n==2) cout<<"Lowest Price is"<<n*8*0.95<<"Yuan"<<Endl; if(n==3) cout<<"Lowest Price is"<<n*8*0.9<<"Yuan"<<Endl; if(n==4) cout<<"Lowest Price is"<<n*8*0.8<<"Yuan"<<Endl; } Else { if(n%5==0) {cout<<i<<"set of 5 copies of the"<<Endl; cout<<"the lowest price is:"<<i*8*5*0.75<<Endl; } if(n%5==1) {cout<<i<<"set of 5 copies"<<Endl; cout<<"Plus"<<n%5<<"this"<<Endl; cout<<"the lowest price is:"<<i*8*5*0.75+ (n%5)*8<<Endl; } if(n%5==2) {cout<<i<<"set of 5 copies"<<Endl; cout<<"Plus"<<n%5<<"this"<<Endl; cout<<"the lowest price is:"<<i*8*5*0.75+ (n%5)*8*0.95<<Endl; } if(n%5==3) {cout<<i-1<<"set of 5 copies of the"<<Endl; cout<<"plus 2 sets of 4 copies"<<Endl; cout<<"the lowest price is:"<< (I-1)*8*5*0.75+2*4*8*0.8<<Endl; } if(n%5==4) {cout<<i<<"set of 5 copies"<<Endl; cout<<"Plus"<<n%5<<"this"<<Endl; cout<<"the lowest price is:"<<i*8*5*0.75+ (n%5)*8*0.8<<Endl; } }}
The lowest price of the book of Software Engineering introduction