菜鸟又来求助大虾了!!!关于JAVA中的LOOP初学者目前在学习,刚接触编程这几题自己也琢磨了一下,可是不知道对不对!!希望大家给我个答案我参考一下!!!谢谢!/***Returnsthenumb...

菜鸟又来求助大虾了!!!

关于JAVA中的LOOP

初学者目前在学习,刚接触编程

这几题自己也琢磨了一下,

可是不知道对不对!!

希望大家给我个答案

我参考一下!!!

谢谢!

/**

* Returns the number of spaces in a String

* Example:

* Input: "We are the champions!"

* Returns: 3

*

* Input: "Until next time..."

* Returns: 2

*/

// HINT: Don't use indexOf, there is an easier way

public static int countOfSpaces(String s) {

return 0; // *** REPLACE THIS LINE WITH YOUR OWN CODE ***

}

/**

* Returns the reverse of a String

* Example:

* Input: "We are the champions!"

* Returns: "!snoipmahc eht era eW"

*

* Input: "Until next time..."

* Returns: "...emit txen litnU"

*/

public static String reverse(String s) {

return ""; // *** REPLACE THIS LINE WITH YOUR OWN CODE ***

}

/**

* Print a rectangle of stars.

* @param numRows number of rows in the rectangle

* @param numColumns number of stars (asterisks) in each row.

*

* For example, printRectangle(3, 5) should output:

*****

*****

*****

*/

public static void printRectangle(int numRows, int numColumns) {

// *** REPLACE THIS LINE WITH YOUR OWN CODE ***

}

/**

* Print a triangle of stars, 1 star in the first row, 2 in the second, etc.

* @param numRows number of rows in the triangle

*

* Shown below (side by side for compactness) are the outputs from calling

* printTriangle(1), printTriangle(3), and printTriangle(6).

* * *

** **

*** ***

****

*****

******

*/

public static void printTriangle(int size) {

// *** REPLACE THIS LINE WITH YOUR OWN CODE ***

}

展开

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐