Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Создайте массив из всех нечётных чисел от 1 до 99, выведите его на экран в строку,
- а затем этот же массив выведите на экран тоже в строку,
- но в обратном порядке (99 97 95 93 … 7 5 3 1).
- */
- public class MaxElementMassiv {
- public static boolean Check(int a){
- if (a%2 == 0)
- return true;
- else
- return false;
- }
- public static void main(String[] args) {
- int mSize=0;
- for (int i = 1; i <= 99; i++) {
- if (Check(i)==false)
- mSize += 1;
- }
- int[] m = new int[mSize];
- int Count=0;
- for (int i = 1; i <= 99; i++) {
- if (Check(i)==false) {
- m[Count] = i;
- Count++;
- }
- }
- // for (int i = 0; i < m.length; i++) {
- // System.out.print(m[i]+" ");
- //
- // }
- for (int i = mSize-1; i >= 0 ; i--) {
- System.out.print(m[i]+" ");
- }
- // for (int i=m.length-1;i>=0;i--) {
- // System.out.print(m[i]+" ");
- // }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement