Java:打印1-100之间9的个数(新解)

public class TestDemo {
	public static void main(String[] args) {
		int i;
		int count = 0;
		for (i=1; i<=100; i++) {
			if(i%10==9) {
				count++;
			}
			if(i/10==9) {
				count++;
			}
		}
		System.out.println(count);
	}
}
发布了82 篇原创文章 · 获赞 0 · 访问量 1195

猜你喜欢

转载自blog.csdn.net/yufy0528/article/details/104728041
今日推荐