samedi 31 octobre 2015

i can't show the output to the user

i wrote that code but every time i try to show the out put to the user by System.out.print statement something goes wrong. "the purpose of the code is to check if the array is “palindromic” "

import java.util.Scanner;
public class u {
public static void main(String[] args) {
    int [] arr = {1,2,3,4,5,2,1};
    int counter1 = 0,counter2 = arr.length-1;
    int x = arr.length/2;
    while (counter1 < x ) {
        if (arr[counter1] == arr [counter2]){
            counter1++;
            counter2--;
        } else break;

    } 


   }}

Aucun commentaire:

Enregistrer un commentaire