牛津大學編程思維挑戰(OUCC)是澳大利亞數學會(AMT)組織參與的信息學比賽之一。OUCC基于計算及算法思維CAT學術活動所使用的一些基本原則,并幫助學生加深發展用程序方法解決計算思維問題。所有題目使用模塊化語言來解決,更高年級的學生需要用編程語言來實現。該學術活動新賽季報名時間已公布,報名通道及學術活動真題開放中!
學術活動時間:
2022年5月8日14:00-15:00(60 分鐘)
Rail Fence Cipher:
The rail fence cipher first appeared in the US civil war. The message to be encrypted is written in a wavelike pattern, down, up, down, up, ... on a fixed number of lines or rails. The cipher text is then read horizontally, rail by rail.
Example:With three rails, the message KOOKABURRAS would be written down as
K A R
O K B R A
O U S
and the encrypted message would be KAROKBRAOUS.
Input format:
A string with 3 - 12 letters.
Output format:
A string of the same length.
Task:
Write a program that encrypts a message using the rail fence cipher.
Note: For Java (and similar) programs the grader expects the name of the main class to be: railfence
知識點:
列表的應用
參考代碼:

想要獲取備賽計劃,考前查缺補漏、重點沖刺
歡迎前來掃描二維碼咨詢【免費領取】歷年學術活動真題及解析!


? 2025. All Rights Reserved. 滬ICP備2023009024號-1