#ZZ03. 找数组最小值
找数组最小值
🔢 找数组最小值
📄 题目描述
妙小程学习了函数与指针后,想编写一个函数能够很方便的找到给定数组中的最小值,他太忙了,写了一半又跑了,所以剩下的需要你来补充完整。
⌨️ 输入格式
输入整数T(1<=T<=100)表示T组数据。 随后有T组数据,每组两行,第一行为数组元素个数n(1<=n<=100)。 第二行为数组的元素,每个数的大小都在int范围内。
#include <bits/stdc++.h>
using namespace std;
int findMin( ){
}
int main() {
int T, a[105];
cin >> T;
while (T--) {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
cout << findMin(a, n) << endl;
}
return 0;
}
📤 输出格式
T行,每组数据中的最小值。
🧪 样例
2
4
1 3 2 5
3
4 9 10
1
4