---
# System prepended metadata

title: Java_Cmoney_ft9107_會不斷讀數字的機器
tags: [Cmoney_Java題目]

---

---
tags: Cmoney_Java題目
---
Java_Cmoney_ft9107_會不斷讀數字的機器
===

![](https://i.imgur.com/mdxUThH.png)


1.主程式
---
將 int 轉成 String ，再使用`.contains()`看有沒有這個數字

```java=
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i <= n; i++) {
            String s = Integer.toString(i);
            if (s.contains("1"))
                continue;
            else
                System.out.print(i+" ");
        }
    }
}
```
