本帖最后由 dan8612 于 2012-11-21 15:33 编辑
- import java.util.Scanner;
- public class DivideTest {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner sc = new Scanner(System.in);
- while(true)
- {
- int num = sc.nextInt();
- if(num==-1)
- break;
- int temp = num;
- int count = 0;
- if(temp<9)
- System.out.println(num+"小于9,可以被"+count+"个9除。");else{ while(temp>=9)
- {
- temp = temp/9;
- count++;
- }
- System.out.println(num+"可以被"+count+"个9除。");
- }
- }
- sc.close();
- }
- }
复制代码 |