12/19homework
public class Equal{
public static void main(String[] args) {
int i;
int[] a={1,9,6,4,0,2,1,2};
int[] b={1,9,6,4,0,2,1,2};
System.out.print("a[]=");
for(i=0;i
System.out.print(" "+a[i]);
}
System.out.println("");
System.out.print("b[]=");
for(i=0;i
System.out.print(" "+b[i]);
}
System.out.println("");
if (equalArrays(a, b))
System.out.println("a and b are equal .");
else
System.out.println("a and b are not equal .");
}
public static boolean equalArrays(int[] a, int[] b)
{
if (a.length != b.length)
return false;
else
{
int i = 0;
while (i < a.length)
{
if (a[i] != b[i])
return false;
i++;
}
}
return true;
}
}
http://home.pchome.com.tw/club/savvygirl/home.JPG
0 Comments:
Post a Comment
<< Home