---
# System prepended metadata

title: 訓練場_5程式繳交處
tags: [訓練場_st]

---

---
title: 訓練場_5程式繳交處
tags: 訓練場_st
---
> [訓練場_5 題目](https://hackmd.io/@futurenest/code_training_5)

> [程式線上編譯環境](https://replit.com/)
:::warning
繳交規範（可以複製這裡的喔）

`### 自己名字`
`#### 題目一` 
```python
程式碼
```
`#### 題目二` 
```c++
程式碼
```
:::

### debug-1
```python
n = int(input('輸入一個正整數:'))
i = 2

while i < n:
  if n % i == 0:
      print('不是質數')
      break

if i == n:
  print('是質數')
```

### debug-2
![](https://i.imgur.com/kUoiKq5.png)

``` python
k = 4
m = 1

for i in range(1, 6):
  for j in range(1, k+1):
    print(' ', end ='')
    j = j + 1
  for j in range(1, m+1):
    print("*", end ='')
    j = j + 1
  print("\n")
  k = k - 1
  m = m + 1
  i = i + 1
```

### debug-3
```python
def is_prime():
  for i in range(2, number):
    if number % i == 0:
      return False
  return True

n = int(input('輸入一個正整數:'))

if is_prime(n):
  print('是質數')
else:
  print('不是質數')
```

### debug-4
```python
A = [80, 50, 70, 40, 60]

# 列印出排序前陣列
print("排序前")
for item in A:
  print(item,' ', end='')
print()

# 列印出排序過程
for i in range(1, len(A))):
  insert = A[i] # 用來存取暫時的資料
  j = i - 1
  while j >= 0:
    if insert < A[j]:
      A[j+1] = A[j] # 把所有元素往後推一個
    else:
      break
    
  A[j+1] = insert # 將最小元素放到第一個
  print("外層迴圈執行", i ,"次結果為") 
  for item in A:
    print(item,' ', end='')
  print()

# 列印出排序後陣列
print("排序後") 
for item in A:
  print(item,' ', end='')
print()
```