diff --git a/【实践课内】8.数组2/7-1 求矩阵的局部极大值.c b/【实践课内】8.数组2/7-1 求矩阵的局部极大值.c new file mode 100644 index 0000000..c9ca0f4 --- /dev/null +++ b/【实践课内】8.数组2/7-1 求矩阵的局部极大值.c @@ -0,0 +1,32 @@ +#include + +int m, n, matrix[25][25], flag; + +int main() { + scanf("%d%d", &m, &n); + + for (int i = 1; i <= m; i++) { + for (int j = 1; j <= n; j++) { + scanf("%d", &matrix[i][j]); + } + } + + for (int i = 2; i <= m - 1; i++) { + for (int j = 2; j <= n - 1; j++) { + if (matrix[i][j] > matrix[i - 1][j] + && matrix[i][j] > matrix[i + 1][j] + && matrix[i][j] > matrix[i][j - 1] + && matrix[i][j] > matrix[i][j + 1]) { + printf("%d %d %d\n", matrix[i][j], i, j); + + flag = 1; + } + } + } + + if (!flag) { + printf("None %d %d\n", m, n); + } + + return 0; +} diff --git a/【实践课内】8.数组2/7-1 求矩阵的局部极大值.jpg b/【实践课内】8.数组2/7-1 求矩阵的局部极大值.jpg new file mode 100644 index 0000000..966df5e Binary files /dev/null and b/【实践课内】8.数组2/7-1 求矩阵的局部极大值.jpg differ diff --git a/【实践课内】8.数组2/7-2 求矩阵各行元素之和.c b/【实践课内】8.数组2/7-2 求矩阵各行元素之和.c new file mode 100644 index 0000000..f62f801 --- /dev/null +++ b/【实践课内】8.数组2/7-2 求矩阵各行元素之和.c @@ -0,0 +1,21 @@ +#include + +int main() { + int m, n; + + scanf("%d%d", &m, &n); + + for (int i = 1; i <= m; i++) { + int x, sum = 0; + + for (int j = 1; j <= n; j++) { + scanf("%d", &x); + + sum += x; + } + + printf("%d\n", sum); + } + + return 0; +} diff --git a/【实践课内】8.数组2/7-2 求矩阵各行元素之和.jpg b/【实践课内】8.数组2/7-2 求矩阵各行元素之和.jpg new file mode 100644 index 0000000..5b17c7f Binary files /dev/null and b/【实践课内】8.数组2/7-2 求矩阵各行元素之和.jpg differ diff --git a/【实践课内】8.数组2/7-3 判断上三角矩阵.c b/【实践课内】8.数组2/7-3 判断上三角矩阵.c new file mode 100644 index 0000000..ad637cb --- /dev/null +++ b/【实践课内】8.数组2/7-3 判断上三角矩阵.c @@ -0,0 +1,35 @@ +#include + +int t, n, mat[15][15]; + +int main() { + scanf("%d", &t); + + while (t--) { + scanf("%d", &n); + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= n; j++) { + scanf("%d", &mat[i][j]); + } + } + + int flag = 1; + + for (int i = 1; i <= n; i++) { + for (int j = 1; j < i; j++) { + if (mat[i][j] != 0) { + flag = 0; + } + } + } + + if (flag) { + printf("YES\n"); + } else { + printf("NO\n"); + } + } + + return 0; +} diff --git a/【实践课内】8.数组2/7-3 判断上三角矩阵.jpg b/【实践课内】8.数组2/7-3 判断上三角矩阵.jpg new file mode 100644 index 0000000..33fd77f Binary files /dev/null and b/【实践课内】8.数组2/7-3 判断上三角矩阵.jpg differ diff --git a/【实践课内】8.数组2/7-5 点赞.c b/【实践课内】8.数组2/7-5 点赞.c new file mode 100644 index 0000000..665965f --- /dev/null +++ b/【实践课内】8.数组2/7-5 点赞.c @@ -0,0 +1,30 @@ +#include + +int n, k, tag_count[1005], max, max_id; + +int main() { + scanf("%d", &n); + + for (int i = 1; i <= n; i++) { + scanf("%d", &k); + + for (int j = 1; j <= k; j++) { + int x; + + scanf("%d", &x); + + tag_count[x]++; + } + } + + for (int i = 1; i <= 1000; i++) { + if (tag_count[i] >= max) { + max = tag_count[i]; + max_id = i; + } + } + + printf("%d %d\n", max_id, max); + + return 0; +} diff --git a/【实践课内】8.数组2/7-5 点赞.jpg b/【实践课内】8.数组2/7-5 点赞.jpg new file mode 100644 index 0000000..4cabc65 Binary files /dev/null and b/【实践课内】8.数组2/7-5 点赞.jpg differ