Q489: Hangman JudgeHangman Judge是一個猜英文單字的小遊戲(在電子字典中常會看到),遊戲規則如下: 答案單字寫在紙上(每個字元一張紙),並且被蓋起來,玩家每次猜一個英文字元(letter)。 如果這個英文字元猜中(在答案的英文單字中有出現),被猜中的字元就被翻開。例如:答案是book,如果你猜o,book中的兩個o就會被視為已猜中。 如果這個英文字元未出現在答案的單字中,就會在hangman的圖中多加一劃。要完成hangman圖共需7劃,如下圖。注意:同一個猜錯的字元只能再圖上畫一劃,例如:答案是book,第一次你猜a(未猜中)會在圖上畫一劃,但第二次... Read More
posted @ 2012-06-03 22:51 godjob Views(340) Comments(0) Diggs(0) Edit
Q445: Marvelous Mazes本題中你的任務是寫一支可以畫迷宮的程式,這個迷宮將由A-Z26個字母及*(星號)和空白字元組成。Input and Output你的程式必須從input讀入迷宮的資訊,輸入將包含數列字元,你的程式必須依照指示畫出迷宮。迷宮的每一列都會藉由一系列的數字和字元來表達,數字代表這個字元被使用多少次。如果數字超過一位數則這個字元重複出現的次數為每一位數相加的總合。在input中小寫的"b"代表空白字元,驚嘆號(!)以及換行都代表結束一列。迷宮的列數並沒有限制,但是每一列不會超過132個字元。Sample Input1T1b5T!1T2b1T Read More
posted @ 2012-06-03 21:31 godjob Views(263) Comments(0) Diggs(0) Edit
Q490: Rotating Sentences在這個問題中你必須將數列文字往順時針方向旋轉90度。也就是說將原本由左到右,由上到下的句子輸出成由上到下,由右到左。Input and Output輸入最多不會超過100列,每列最多不會超過100個字元。 合法的字元包括:換行,空白,所有的標點符號,數字,以及大小寫字母。(注意:Tabs並不算是合法字元。)最後一列輸入必須垂直輸出在最左邊一行,輸入的第一列必須垂直輸出在最右邊一行。請參考sample intput/output。Sample InputRene Decartes once said,"I thin... Read More
posted @ 2012-06-03 16:45 godjob Views(376) Comments(0) Diggs(0) Edit
Kindergarten Counting GameEverybody sit down in a circle. Ok. Listen to me carefully.``Woooooo, you scwewy wabbit!''Now, could someone tell me how many words I just said?Input and OutputInput to your program will consist of a series of lines, each line containing multiple words (at least one Read More
posted @ 2012-06-03 16:41 godjob Views(351) Comments(0) Diggs(0) Edit
3*x^4+6*x^3+2*x^2+5*x+6求值的过程为33*x + 63*x^2 +6*x+23*x^3 +6*x^2+2*x+53*x^4 +6*x^3+2*x^2+5*x+6#include <iostream>#include <stdlib.h>#include <stdio.h>using namespace std;int main(){ printf("多项式求值的Horner算法n"); printf("n说明:对于求多项式3*x^4+6*x^3+2*x^2+5*x+6当x=2 时的值,应该按以下输入n&qu Read More
posted @ 2012-06-03 14:48 godjob Views(1028) Comments(0) Diggs(0) Edit
在网上看到的一个比较好的The 3n+1 problem,通过中间变量来保存结果集,较少了运算数量 1 #include <iostream> 2 3 #include <vector> 4 5 6 7 #define SIZE 100000 8 9 10 11 using namespace std;12 13 14 15 int Count(vector<int> &viRec, int iNum)16 17 {18 19 int iTemp=iNum, iResult=0;20 21 22 23 if (viRec[iTemp]!=0) ret Read More
posted @ 2012-06-03 14:43 godjob Views(213) Comments(0) Diggs(0) Edit