---
# System prepended metadata

title: 第五關程式繳交處
tags: [關卡_st]

---

---
title: 第五關程式繳交處
tags: 關卡_st
---

> [第五關題目](https://hackmd.io/@futurenest/code_challenge_5)

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

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

---
### 林永晉
#### 題目一：
```python=
def max(ans):   #設定找出最大串列模組
    M = ans[0]   #設定 M 等於索引 0
    index = 0   #先設定 0 最大
    for i in range(1,len(ans)):
        if ans[i] > M:   #當索引 i 大於 M(索引 0)
            M = ans[i]   #M 被索引 i 給取代
            index = i   #把 i 最大值給 index
    return index  

ans = list(eval(input('請輸入陣列:')))
ans.sort()   #從小到大排序
print('第二大的數為：',ans[max(ans) - 1])
```
#### 題目二：
```python=
def cal(number):
    lst = []
    i = 2   #起始值
    while i * i <= number:   #條件
        if number % i:   #資料名稱
            i += 1
        else:
            number = number // i
            lst.append(i)
    if number > 1:
        lst.append(number)
    return lst

print(cal(eval(input('enter a number:'))))
```

---------------------------------------------------------

### 王政翔
#### 題目一
```cpp=
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const std::string WHITESPACE = " \n\r\t\f\v";

std::string ltrim(const std::string &s){
    size_t start = s.find_first_not_of(WHITESPACE);
    return (start == std::string::npos) ? "" : s.substr(start);
}
 
std::string rtrim(const std::string &s){
    size_t end = s.find_last_not_of(WHITESPACE);
    return (end == std::string::npos) ? "" : s.substr(0, end + 1);
}
 
std::string trim(const std::string &s){
    return rtrim(ltrim(s));
}

int main(){
    string text;
    string delimiter = ",";
    string nums[256];
    string temp;
    
    getline(cin, text);

    int count = 0;
    int zeronum = 0;
    string num;
    size_t pos = 0;
    string zero[256];
  
    while ((pos = text.find(delimiter)) != string::npos){
        num = text.substr(0, pos);
        if(num == "0"){
            zero[zeronum++] = trim(num);
        } else {
	      nums[count++] = trim(num);
	  }
        text.erase(0, pos + delimiter.length() + 1);
    }

    nums[count] = trim(text);
    
    for(int i = 0; i <= count; i++){
        for(int j = 0; j < count-i; j++){
            if(nums[j] < nums[j+1]){
		    temp = nums[j];
		    nums[j] = nums[j+1];
		    nums[j+1] = temp;
		}
	  }
    }
    
    cout << nums[1];
    
    return 0;
}
```
#### 題目二
```cpp=
#include <iostream>
using namespace::std;

int main(){
    int n;
    int i = 0;
    int x = 2;
    int array[256];
    
    cin >> n;
    
    while(n > 1){
        while(n % x == 0){
	      array[i] = x;
	      n = n / x;
	      i++;
	  }
	  x++;
    }
    
    cout << "[";
    for(int j = 0; j < i; j++){
        cout << array[j];
        
	  if(j != i-1){
	      cout << ", ";
	  }
    }
    cout << "]";
    
    return 0;
}
```


### 鍾宇哲
#### 題目一 
```python=
a = [input(), input(), input(), input(), input()]
for j in range(len(a)-1):
    for i in range(len(a)-1-j):
        if a[i]>a[i+1]:#比大小
            tmp = a[i]
            a[i] = a[i+1]
            a[i+1] = tmp

print(a)
print(a[3])



```
#### 題目二
```python=


```
-------

### 張云綺
#### 第一題
```python=
a = [6,4,7,8,9,2]
b = sorted(a)
print(b)
c = sorted(a, reverse=True)
print(c[1])

```
#### 題目二
```python=

```


----