标签:
一.题目
1 // ConsoleApplication6.cpp : 定义控制台应用程序的入口点。 2 // 3 #include "stdafx.h" 4 int _tmain(int argc, _TCHAR* argv[]) 5 { 6 return 0; 7 } 8 #include<iostream> 9 using namespace std; 10 float price; 11 void tanxin(int book) 12 { 13 int yushu; 14 yushu = book % 5; 15 switch (yushu) 16 { 17 case 0: 18 price = book * 8 * 0.75; 19 break; 20 case 1: 21 price = (book - yushu) * 8 * 0.75 + 8; 22 break; 23 case 2: 24 price = (book - yushu) * 8 * 0.75 + 2 * 8 * 0.95; 25 break; 26 case 3: 27 price = (book - yushu) * 8 * 0.75 + 4 * 8 * 0.8 * 2 - 5 * 8 * 0.75; 28 if (book<5) 29 { 30 price += 0.4; 31 } 32 break; 33 case 4: 34 price = (book - yushu) * 8 * 0.75 + 4 * 8 * 0.8; 35 break; 36 default: 37 cout << "Error!" << endl; 38 39 } 40 } 41 void main() 42 { 43 int i= 0; 44 while (i== 0) 45 { 46 int book; 47 cout << "购买本数(tip:输入正整数):"; 48 cin >> book; 49 tanxin(book); 50 cout << "最低价格:" << price << endl; 51 cout << "还要买吗?(tip:输入0继续,输入任意键退出)"; 52 cin >> i; 53 } 54 }
标签:
原文地址:http://www.cnblogs.com/littilsaber/p/4429303.html