题解 | #牛牛的二三七整除#

牛牛的二三七整除

http://www.nowcoder.com/practice/b2cf0b791245436f8f0591ae9f4c664f

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int[] b = {2,3,7};
        int c = 0;		//计数器
        for(int i = 0; i<3; i++){
            if(a%b[i] == 0){
                System.out.print(b[i]+" ");  
                c++; 
            }
        }
        if(c == 0){ 	//如果计数器没动,说明没整除
            System.out.println("n");
        }
            
    }
}


全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务