求数组中能被3整除的元素并打印输出。


我这个程序执行定义一个数组,通过键盘输入数组元素,在输入的数组元素中找到能被3整除的元素并打印输出


int ar[]=new int [5];
		Scanner sc=new Scanner(System.in);
		for(int i=0;i<5;i++) {
			ar[i]=sc.nextInt();
		}
		for(int j=0;j<5;j++) {
			if(ar[j]%3==0) System.out.println(ar[j]+"元素能被3整除");
		}

猜你喜欢

转载自blog.csdn.net/IGGIRing/article/details/88282961