1003 我要通過! 20

2021-07-24 04:16:36 字數 762 閱讀 4642

先貼上題目

這個題目從開始思考,到最終得到「答案正確」的時間跨度很長,主要原因有:

1. 題目要求分析不清

2. 實現時,出現幾個困難點:

* 1 如何讀入多個字串?(最初出現問題可能是由於沒有注意到題目中要求字串長度不超過100)

* 2 陣列元素個數未知,如何避免出現錯誤?

this is the code.

#include 

#include

#include

int main()

if (p != 1 || t != 1 || oth)

printf("no\n");

//judged from p, t and oth, i will know if there is one p, one t, and no other characters in the string.

else

else printf("no\n");}}

return

0;}

另:

2. 關於「段錯誤」問題可以深究

1003 我要通過! 20

pat1003 規則1和2是基本要求 規則3 apbtc apbatca,那麼可以逆推 apbatca 到 apbtc,直到 a pata 這種形式,說明源字串是符合要求的 詳細說明 apbtc,則b中每次減少乙個a,c中減少a字串,直到cpatd形式,若c d,則說明滿足規則2,即原串符合要求 i...

1003 我要通過! 20

1.字串中必須僅有p,a,t這三種字元,不可以包含其它字元 2.任意形如 xpatx 的字串都可以獲得 答案正確 其中 x 或者是空字串,或 者是僅由字母 a 組成的字串 3.如果 apbtc 是正確的,那麼 apbatca 也是正確的,其中 a,b,c 均或者是空字串,或者是僅由字母 a 組成的字...

1003 我要通過! 20

這道題題目有點難懂,只能總結出規律 設p前面 的個數為 和 之間的a的個數為b t後面的個數為c 結論 a b c 通過第二條 這裡注意兩個x是乙個變數 可以得到 n 1 n是正確的 第三條說明 n 2 2n是正確的把這一條繼續帶入第三條 得到 n 3 3n是正確的。結果顯而易見。include u...