标签:
1 #include<iostream.h> 2 int main(){ 3 int num; 4 int m,n; 5 float sum; 6 cout<<"请输入要购买的书的本书:"; 7 cin>>num; 8 m=num/5; 9 n=num%5; 10 if(num!=3) 11 { 12 switch(n) 13 { 14 case 0: 15 sum=num*8*0.75; 16 break; 17 case 1: 18 sum=m*5*8*0.75+8; 19 break; 20 case 2: 21 sum=m*5*8*0.75+2*8*0.95; 22 break; 23 case 3: 24 sum=(m-1)*5*8+4*8*0.8+4*8*0.8; 25 break; 26 case 4: 27 sum=m*5*0.75+4*8*0.8; 28 break; 29 } 30 } 31 else 32 sum=3*8*0.9; 33 cout<<"读者购买一批书的最低价格为:"<<sum<<"元"<<endl; 34 return 0; 35 }
截图:
标签:
原文地址:http://www.cnblogs.com/xuqingtian/p/4429272.html