LoginSignup
6
6

More than 5 years have passed since last update.

ズンドコキヨシ with Java 短く書いた

Last updated at Posted at 2016-03-16

流行ってたのでつい・・・

Kiyoshi.java
public class Kiyoshi {
  public static void main(String[] args) {
    String s = "";
    do {
      s += Math.random() > 0.5 ? "ズン" : "ドコ";
    } while (!s.endsWith("ズンズンズンズンドコ"));
    System.out.println(s + "キ・ヨ・シ!");
  }
}

やっぱJavaだし長く感じるよなー。

3/17 追記

出力は毎回なのか・・・というわけで version 2

Kiyoshi2.java
public class Kiyoshi2 {
  public static void main(String[] args) {
    String s = "";
    do {
      String zd = Math.random() > 0.5 ? "ズン" : "ドコ";
      System.out.print(zd);
      s += zd;
    } while (!s.endsWith("ズンズンズンズンドコ"));
    System.out.println("キ・ヨ・シ!");
  }
}

長くなっちまった・・・

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6