Created
July 18, 2013 14:44
-
-
Save shikajiro/6029916 to your computer and use it in GitHub Desktop.
long型の10個の配列に0から100までのランダムな値を入れてください。 それら中から、3で割り切れる数値または5で割り切れる数値だけを画面に表示してください。
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 HomeWork { | |
public static void main(String[] args) { | |
long[] numbers = new long[10]; | |
for (int i = 0; i < numbers.length; i++) { | |
numbers[i] = new Random().nextInt(101); | |
} | |
for (long l : numbers) { | |
if (l % 3 == 0 || l % 5 == 0) { | |
System.out.println(l); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment