Advertisement
Guest User

Untitled

a guest
May 27th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. package BaiTap;
  2.  
  3. import java.util.Scanner;
  4. public class MangChiaHetCho3 {
  5.  
  6. public static void main(String[] args) {
  7. Scanner sc = new Scanner(System.in);
  8. System.out.print("Nhap so luong so: ");
  9. int soLuong = sc.nextInt();
  10.  
  11. int arr[] = new int[soLuong];
  12.  
  13. for(int i = 0; i < soLuong; i++) {
  14. System.out.print("Nhap so thu" + i + ": ");
  15. arr[i] = sc.nextInt();
  16.  
  17. }
  18.  
  19. for(int i = 0; i < soLuong; i++) {
  20. if(arr[i] % 3 == 0){
  21. System.out.print("Cac so chia het cho 3 la \n" +arr[i]+ "\n");
  22. }
  23.  
  24. }
  25.  
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement