NLKappa

Schoolwork arrays

Oct 2nd, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         int a = 0;
  7.         System.out.println("Введите колиество чисел в массиве: ");
  8.         Scanner sc = new Scanner(System.in);
  9.         int n = sc.nextInt();
  10.         int[] num = new int[n];
  11.         for (int i = 0; i < n; i++) {
  12.             System.out.printf("Введите число массива под номером %d: ", i);
  13.             num[i] = sc.nextInt();
  14.         }
  15.         for (int j = 1; j < n; j++) {
  16.             if (num[j] > num[j-1]) {
  17.                 a = a + 1;
  18.             }
  19.         }
  20.         System.out.printf("Чисел получилось: %d", a);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment