편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.
최신판 | 당신의 편집 | ||
22번째 줄: | 22번째 줄: | ||
[[분류: Java]] | [[분류: Java]] | ||
{{참고|Java str_repeat()}} | {{참고|Java str_repeat()}} | ||
<syntaxhighlight lang='Java' | <syntaxhighlight lang='Java'> | ||
public class MyClass { | public class MyClass { | ||
public static String str_repeat(String str, int times) { | public static String str_repeat(String str, int times) { | ||
28번째 줄: | 28번째 줄: | ||
} | } | ||
public static void main(String args[]) { | public static void main(String args[]) { | ||
System.out.println( str_repeat("hello",3) ); // hellohellohello | System.out.println( str_repeat("hello",3) ); | ||
// hellohellohello | |||
} | } | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang='Java' | <syntaxhighlight lang='Java'> | ||
public class MyClass { | public class MyClass { | ||
public static String str_repeat(String str, int times) { | public static String str_repeat(String str, int times) { | ||
40번째 줄: | 41번째 줄: | ||
} | } | ||
public static void main(String args[]) { | public static void main(String args[]) { | ||
System.out.println( str_repeat("hello",3) ); // hellohellohello | System.out.println( str_repeat("hello",3) ); | ||
// hellohellohello | |||
} | } | ||
} | } | ||
47번째 줄: | 49번째 줄: | ||
==JavaScript== | ==JavaScript== | ||
[[category: JavaScript]] | [[category: JavaScript]] | ||
<syntaxhighlight lang='JavaScript' | <syntaxhighlight lang='JavaScript'> | ||
String.prototype.repeat=function(n){return new Array(n+1).join(this)} | String.prototype.repeat=function(n){return new Array(n+1).join(this)} | ||
console.log( "hello".repeat(3) ); // hellohellohello | console.log( "hello".repeat(3) ); | ||
// hellohellohello | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==Perl== | ==Perl== | ||
[[분류: Perl]] | [[분류: Perl]] | ||
<syntaxhighlight lang='Perl' | <syntaxhighlight lang='Perl'> | ||
print "hello" x 3 # hellohellohello | print "hello" x 3 | ||
# hellohellohello | |||
</syntaxhighlight> | </syntaxhighlight> | ||
66번째 줄: | 65번째 줄: | ||
[[category: PHP]] | [[category: PHP]] | ||
{{참고|PHP str_repeat()}} | {{참고|PHP str_repeat()}} | ||
<syntaxhighlight lang='PHP' | <syntaxhighlight lang='PHP'> | ||
echo str_repeat("hello", 3); // hellohellohello | echo str_repeat("hello", 3); | ||
// hellohellohello | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==Python== | ==Python== | ||
[[category: Python]] | [[category: Python]] | ||
<syntaxhighlight lang='Python' | <syntaxhighlight lang='Python'> | ||
print | print "hello" * 3 | ||
# hellohellohello | |||
</syntaxhighlight> | </syntaxhighlight> | ||