• 咨询电话 13023111482
  • 犀牛首页
  • IB课程
  • AP课程
  • G5笔面试
  • AMC竞赛
  • HMMT竞赛
  • 物理碗竞赛
犀牛教育
  • AP力学真题
  • AP物理1真题
  • AP物理2真题
  • AP计算机真题
  • AP生物真题
  • AP化学真题
  • AP电磁学真题

AP计算机真题

首页 > AP > AP计算机 > AP计算机真题

2014年AP计算机简答题真题PDF下载

2021-08-10

2014年AP计算机简答题真题PDF下载

1. This question involves reasoning about strings made up of uppercase letters. You will implement two related methods that appear in the same class (not shown). The first method takes a single string parameter and returns a scrambled version of that string. The second method takes a list of strings and modifies the list by scrambling each entry in the list. Any entry that cannot be scrambled is removed from the list.

(a) Write the method scrambleWord, which takes a given word and returns a string that contains a scrambled version of the word according to the following rules.

  • The scrambling process begins at the first letter of the word and continues from left to right. 
  • If two consecutive letters consist of an "A" followed by a letter that is not an "A", then the two letters are swapped in the resulting string.
  • Once the letters in two adjacent positions have been swapped, neither of those two positions can be involved in a future swap.

The following table shows several examples of words and their scrambled versions.

Complete method scrambleWord below.

/** Scrambles a given word.

* @param word the word to be scrambled

* @return the scrambled word (possibly equal to word)

* Precondition: word is either an empty string or contains only uppercase letters.

* Postcondition: the string returned was created from word as follows:

* - the word was scrambled, beginning at the first letter and continuing from left to right

* - two consecutive letters consisting of "A" followed by a letter that was not "A" were swapped

* - letters were swapped at most once

*/

public static String scrambleWord(String word)

 

(b) Write the method scrambleOrRemove, which replaces each word in the parameter wordList with its scrambled version and removes any words that are unchanged after scrambling. The relative ordering of the entries in wordList remains the same as before the call to scrambleOrRemove.

The following example shows how the contents of wordList would be modified as a result of calling scrambleOrRemove.

Before the call to scrambleOrRemove:

Assume that scrambleWord is in the same class as scrambleOrRemove and works as specified, regardless of what you wrote in part (a).

Complete method scrambleOrRemove below.

/** Modifies wordList by replacing each word with its scrambled

* version, removing any words that are unchanged as a result of scrambling.

* @param wordList the list of words

* Precondition: wordList contains only non-null objects

* Postcondition:

* - all words unchanged by scrambling have been removed from wordList

* - each of the remaining words has been replaced by its scrambled version

* - the relative ordering of the entries in wordList is the same as it was

* before the method was called

*/

public static void scrambleOrRemove(List wordList)

2014年AP计算机简答题真题余下省略!


你可能还关注

  1. 2021年AP计算机简答题真题PDF下载 2021-08-10   
    2021年AP计算机简答题真题PDF下载
    详情阅读
  2. 2019年AP计算机简答题真题PDF下载 2021-08-10   
    2019年AP计算机简答题真题PDF下载
    详情阅读
  3. 2018年AP计算机简答题真题PDF下载 2021-08-10   
    2018年AP计算机简答题真题PDF下载
    详情阅读
  4. 2017年AP计算机简答题真题PDF下载 2021-08-10   
    2017年AP计算机简答题真题PDF下载
    详情阅读
  5. 2016年AP计算机简答题真题PDF下载 2021-08-10   
    2016年AP计算机简答题真题PDF下载
    详情阅读

扫码免费下载真题

AP计算机真题

  • 2021年AP计算机简答题真题PDF下载
  • 2019年AP计算机简答题真题PDF下载
  • 2018年AP计算机简答题真题PDF下载
  • 2017年AP计算机简答题真题PDF下载
  • 2016年AP计算机简答题真题PDF下载
  • 2015年AP计算机简答题真题PDF下载
犀牛国际

犀牛国际(X-NEW),由业内多名教学专家共同组建,不乏来自加州理工大学、剑桥大学、清华大学、北京大学、复旦大学、新加坡国立大学等国际一流大学。 其中有博士、硕士的学历老师众多,学术功底扎实,有的已经执教十余年,国际领域经验丰富。

国际学科

  • IB课程辅导
  • AP课程培训
  • A-Level课程培训
  • IGCSE课程辅导

国际竞赛

  • AMC数学竞赛
  • AIME数学竞赛
  • HiMCM竞赛
  • PUMaC竞赛
  • HMMT竞赛
  • 滑铁卢数学竞赛
  • 物理碗竞赛
  • BPhO竞赛
  • BAAO竞赛
  • USNCO竞赛
  • UKCHO竞赛
  • CCC竞赛
  • USABO竞赛
  • BBO竞赛
  • BRAIN BEE

G5笔面试

  • STEP
  • PAT
  • ECAA
  • LNAT
  • MAT
  • TSA
  • NSAA
  • BMAT
  • ENGAA
  • CTMUA
犀牛国际 版权所有 沪ICP备2021004381号-1