Повторите данную строку ровно n раз
// Repeat the given string exactly n times
fn repeat_str(src: &str, count: usize) -> String {
vec![src; count].join("")
}
Mackerel
// Repeat the given string exactly n times
fn repeat_str(src: &str, count: usize) -> String {
vec![src; count].join("")
}
# Repeat the given string exactly n times
def repeat_str (n, s)
s*n
end
// Repeat the given string exactly n times
import java.util.Collections
object StringRepeat {
def repeatStr(times: Int, str: String): String = {
str * times
}
}
// Repeat the given string exactly n times
public class Solution {
public static String repeatStr(final int repeat, final String string) {
String repeatedString = "";
for (int i = 0; i < repeat; i++) {
repeatedString += string;
}
return repeatedString;
}
}
import java.util.Collections;
public class Solution {
public static String repeatStr(final int repeat, final String string) {
return repeat < 0 ? "" : String.join("", Collections.nCopies(repeat, string));
}
}