【问题标题】:This is a run length encoding program for our partner assignment.这是我们的合作伙伴分配的运行长度编码程序。
【发布时间】:2016-04-21 23:36:02
【问题描述】:

我们正在尝试执行 Javadoc 上的指令。到目前为止,我们有这个,但对索引参数感到困惑

 * Read the next run (or single character) and return the index of the symbol following the run (or symbol read).
   * Store the count and symbol for the run in the run parameter.
   * @param line - the input line being processed
   * @param index - the index of the first character in the next "run" (which might be just a single character)
   * @param run - where to store the symbol and count for the Run
   * @return the index of the symbol following the run just read
   */
  static int getNext(String line, int index, Run run) {
    line.charAt(index); //char first, something about a line
    return ?.symbol;//Store values
    run.count= ?.count; //the given number of that specific symbol or repetition
    enter code here
    run.symbol= ?.symbol; //whatever symbol you first see
    // TO BE COMPLETED

    return index+1;// just to make it advance so starter program doesn't loop infinitely
  }
}

【问题讨论】:

  • 问题是什么?

标签: java run-length-encoding


【解决方案1】:

这不是实际的 RLE 压缩函数,而是一个辅助函数,用于计算正在由主 RLE 压缩函数处理的当前字符的重复次数。

这似乎需要做的是:

  • 获取字符串line 的索引index 处的字符,并将其存储在Run 对象的相应属性中。
  • 遍历索引index 之后的line 中的字符,直到遇到与一开始使用的字符不同的字符。
  • 将找到的重复次数存储在 Run 对象的相应属性中。
  • 返回字符串中遇到不相等字符的位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多