Last active
August 29, 2015 14:17
-
-
Save mizucoffee/095c051a11182b1520cb to your computer and use it in GitHub Desktop.
プログラミング生放送 俳句コンテスト Array ver.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Array_Haiku { | |
public static void main(String[] args) throws Exception { | |
int num = 6;//俳句の数 | |
int ran = new Random().nextInt(num);//変数ranにnumの数の乱数を振る | |
String[] data = new String[num];//配列の定義 | |
data[0] = "プログラマ/いのちけずって/今日も行く";//配列の中に、内容を入力。"/"で分ける | |
data[1] = "プロ生ちゃん/プログラマーの/癒しの子"; | |
data[2] = "スパゲッティ/見かけるだけで/寒気する"; | |
data[3] = "FFと/聞いて思うは/255"; | |
data[4] = "野田さんと/一緒に仕事を/してみたい"; | |
data[5] = "できますと/言った直後に/後悔が"; | |
String[] strAry = data[ran].split("/");//ranの数字の配列を"/"で3つの配列に分ける。 | |
String a = "" + strAry[0] + " ";//改行の為にスペースを取る | |
String b = " " + strAry[1] + " "; | |
String c = " "+ strAry[2] + " "; | |
for (int i = 0; i < 9; i++){//繰り返して表示していく。 | |
System.out.print(c.substring(i,i+1)); | |
System.out.print(b.substring(i,i+1)); | |
System.out.println(a.substring(i,i+1)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment