Guest User

Untitled

a guest
Jan 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1.  
  2. public class Prac12 {
  3.    
  4.     /**
  5.      * @pre     the sequence s is assumed to contain at least one negative number.
  6.      * */
  7.     public static int sequenceLength(int[] s)
  8.     {
  9.         int i;
  10.         for (i = 0; i < s.length; i++)
  11.         {
  12.             if (s[i] >= 0)
  13.             {
  14.                 System.out.println(i);
  15.             }
  16.         }
  17.         return i;
  18.     }
  19.    
  20.     public static void main(String[] args) {
  21.         int[] s = {4, 5, 6, 7, -1};
  22.         sequenceLength(s);
  23.     }
  24.  
  25. }
Add Comment
Please, Sign In to add comment