int main(void) { struct book library[MAXBKS]; // book struct array int count = 0; int index; printf("Please enter the book title.\n"); printf("Press [enter] at the satrt of a line to stop.\n"); while (count < MAXBKS && gets(library[count].title) != NULL && library[count].title[0] != '\0') { printf("Now enter the author.\n"); gets(library[count].author); printf("Now enter the value.\n"); scanf("%f", &library[count++].value); while (getchar() != '\n') continue; if (count < MAXBKS) printf("Enter the next title.\n"); } if (count > 0) { printf("Here is the list of your books: \n"); for (index = 0; index < count; index++) printf("%s by %s: $%.2f\n", library[index].title, library[index].author, library[index].value ); puts("In alphabetical order: "); alphabetSort(library, count); puts("In value order: "); valueSort(library, count); } else printf("No books? Too bad.\n"); system("pause"); return 0; }
void Game::rules() { cout << "****************** Monopoly: Empire Rules ********************************" << endl; cout << "I. Basic rules" << endl; cout << " A. Each player has 1000K at beginning and start at position #0." << endl; cout << " B. In each turn, player roll 2 dices, and move corresponding steps." << endl; cout << " C. When stop at a position, follow the instruction of that position." << endl; cout << " D. [1] represent player, [2] represent computer." << endl; cout << endl; cout << "II. Game Board" << endl; cout << " A. Total 24 positions (0~24) of 7 types." << endl; cout << " B. Start" << endl; cout << " 1. Every player start from here." << endl; cout << " 2. When pass start point, collect as much money as your total collecting value." << endl; cout << " C. Billboard" << endl; cout << " 1. Containing name, price, collecting value, and condition(0,1 or 2)." << endl; cout << " 2. The first two lines are the name of the brand." << endl; cout << " 3. The third line is price (collecting value), eg.100K (50)." << endl; cout << " a. Price ≠ collecting value." << endl; cout << " b. Price is how much cost you to buy the brand." << endl; cout << " c. Collecting value is used for win the game." << endl; cout << " 4. The fourth line is (condition), eg. (1)." << endl; cout << " (0 = no owner; 1 = player own; 2 = computer own)" << endl; cout << " 5. The fifth line shows player's position, eg.[1] [2]." << endl; cout << " 6. The bottom line has the position # of that box." << endl; cout << " 7. Exception: Electric Company Billboard. (See IV. Billboard-E)" << endl; cout << " D. Chance Card" << endl; cout << " 1. Randomly pick a chance card when stop at here." << endl; cout << " 2. Total 8 kinds of chance cards." << endl; cout << " 3. Chance card may not be good for player who pick it." << endl; cout << " E. Jail" << endl; cout << " 1. To get out of jail, there are two choice." << endl; cout << " a. During next turn, pay 100K and get out at once." << endl; cout << " b. Roll a double up to 3 turns, if not, pay 50K and get out at 3rd turn." << endl; cout << " 2. Position #19 is go to jail, player will be move to jail on Position #7." << endl; cout << " 3. Simply stop at position #7 is pass by, is not in jail." << endl; cout << " F. Take a trip" << endl; cout << " 1. You can spend 100K to move to anywhere on board, or simply do nothing." << endl; cout << " 2. If you move to a new position, you have to follow the instruction on that position." << endl; cout << " E. Tower Tax" << endl; cout << " 1. Tower Tax: return your topmost billboard to board." << endl; cout << " 2. Rival Tower Tax: return your opponent's topmost billboard to board." << endl; cout << endl; cout << "III. Dices" << endl; cout << " A. One normal dice, one special dice with a 'swap' face." << endl; cout << " B. When 'swap' face is up, you have a chance of sneaky swap." << endl; cout << " (sneaky swap: swap your topmost billboard with your opponent's)" << endl; cout << " C. When you roll a double, you can have another turn until you don't have a double." << endl; cout << " (double: two dices have same number)" << endl; cout << endl; cout << "IV. Billboard" << endl; cout << " A. 14 billboards total; different price with different collecting value; choose smartly!" << endl; cout << " B. You can buy billboards when you stop at the corresponding position if the condition is no owner." << endl; cout << " C. You have to pay rent fee if you stop at a position whose billboard is owner by your opponents." << endl; cout << " D. Nothing will happen if you stop at the position that is owned by yourself." << endl; cout << " E. One exception is Electric Company Billboard at position #9." << endl; cout << " 1. Has 4 in total" << endl; cout << " 2. Doesn't own by anyone." << endl; cout << endl; cout << "V. Chance Card" << endl; cout << " A. Suggestion: Better read card function before playing game." << endl; cout << " B. Explanation of each card:" << endl; cout << " 1.Speed ahead!\nMove forward to 5 space." << endl; cout << " 2.Casino night!\nBoth you and your opponent roll.\nHighest-roller collects 200K from the bank." << endl; cout << " 3.Profits soar!\nAdvance to GO to collect your tower value." << endl; cout << " 4.Launch your website!\nSales skyrocket!\nCollect 300K from the bank." << endl; cout << " 5.Solar power bonus!\nTake a free Electric Company billboard.\nAdd it to your tower.\nIf none are available, do nothing." << endl; cout << " 6.Insider trading fine!\nPay the Bank 200K." << endl; cout << " 7.Tallest tower bonus!\nCheck what the highest tower is currently worth.\nCollect that amount from the bank." << endl; cout << " 8.Go To Jail!\nDo not collect cash for passing GO." << endl; cout << endl; cout << "VI. Win" << endl; cout << " A. Whoever first get 800 collecting value wins." << endl; cout << " B. Whoever first run out of money loses." << endl; cout << endl; cout << "VII. Bonus" << endl; cout << " The bonus area will be open for player each time when player win a game." << endl; cout << "VIII. Tips For Brand Buying" << endl; cout << " A. The unit value for different brand is different. Be wise to choose which brand to buy!" << endl; cout << " B. The brand unit value sorting (large -> small):" << endl << endl; valueSort(); cout << endl; }