From a91c649ef7dea757bfa45e95eb5e67468a4e8135 Mon Sep 17 00:00:00 2001 From: Bluemangoo Date: Tue, 6 May 2025 18:53:26 +0800 Subject: [PATCH] done --- 0410/10.c | 18 ++++++++++++++++++ 0410/11.c | 31 +++++++++++++++++++++++++++++++ 0410/9.c | 23 +++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 0410/10.c create mode 100644 0410/11.c create mode 100644 0410/9.c diff --git a/0410/10.c b/0410/10.c new file mode 100644 index 0000000..b833986 --- /dev/null +++ b/0410/10.c @@ -0,0 +1,18 @@ +#include + +void fun(int a, int b, int *sum, int *diff, int *product, float *divide) { + *sum = a + b; + *diff = a - b; + *product = a * b; + *divide = (float)a / b; +} + +int main() { + int a, b; + int sum, diff, product; + float divide; + scanf("%d %d", &a, &b); + fun(a, b, &sum, &diff, &product, ÷); + printf("%d %d %d %.2f\n", sum, diff, product, divide); + return 0; +} \ No newline at end of file diff --git a/0410/11.c b/0410/11.c new file mode 100644 index 0000000..e15d354 --- /dev/null +++ b/0410/11.c @@ -0,0 +1,31 @@ +#include +#define for_i(i, range, inner) \ + { \ + int i; \ + for (i = 0; i < range; i++) \ + inner; \ + } + +int search(int x[], int n, int *count) { + int cnt = 0, max_num = -1; + for_i(i, n, { + if (x[i] > max_num) { + max_num = x[i]; + cnt = 1; + } else if (x[i] == max_num) { + cnt++; + } + }); + *count = cnt; + return max_num; +} + +int main() { + int n, count, max_num; + int x[1005]; + scanf("%d", &n); + for_i(i, n, scanf("%d", &x[i])); + max_num = search(x, n, &count); + printf("%d %d\n", max_num, count); + return 0; +} \ No newline at end of file diff --git a/0410/9.c b/0410/9.c new file mode 100644 index 0000000..d5034b6 --- /dev/null +++ b/0410/9.c @@ -0,0 +1,23 @@ +#include +#define for_i(i, range, inner) \ + { \ + int i; \ + for (i = 0; i < range; i++) \ + inner; \ + } + +int main() { + int m, n, max_m, max_n, max_num = -1, *p; + scanf("%d %d", &m, &n); + for_i(i, m, for_i(j, n, { + int num; + scanf("%d", &num); + if (num > max_num) { + max_num = num; + max_m = i; + max_n = j; + } + })); + printf("%d %d %d\n", max_num, max_m + 1, max_n + 1); + return 0; +} \ No newline at end of file