Facebook
From XD, 1 Week ago, written in Plain Text.
This paste is a reply to Untitled from Silly Ibis - view diff
Embed
Download Paste or View Raw
Hits: 46
  1. public static void main(String[] args) {
  2.         int[] a = {2, 3, 2, 4, 3, 1, 6, 3, 2, 3};
  3.         System.out.println("# of even: " + countEven(a, 0));
  4.  
  5.     }
  6.  
  7.     public static int countEven(int[] a, int from) {
  8.         Scanner scan = new Scanner(System.in);
  9.         int b = scan.nextInt();
  10.         int even = 0;
  11.         for (int i = b; i < a.length; i++) {
  12.             if (i % 2 == 0) {
  13.                 even++;
  14.             }
  15.         }return even;
  16.     }

Replies to Re: Untitled rss

Title Name Language When
Re: Re: Untitled Cute Madrill text 1 Week ago.