Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Prac12 {
- /**
- * @pre the sequence s is assumed to contain at least one negative number.
- * */
- public static int sequenceLength(int[] s)
- {
- int i;
- for (i = 0; i < s.length; i++)
- {
- if (s[i] >= 0)
- {
- System.out.println(i);
- }
- }
- return i;
- }
- public static void main(String[] args) {
- int[] s = {4, 5, 6, 7, -1};
- sequenceLength(s);
- }
- }
Add Comment
Please, Sign In to add comment