diff --git a/【实践课外】7.数组1/7-12 数组-值钱的微信号.c b/【实践课外】7.数组1/7-12 数组-值钱的微信号.c new file mode 100644 index 0000000..d1250d7 --- /dev/null +++ b/【实践课外】7.数组1/7-12 数组-值钱的微信号.c @@ -0,0 +1,32 @@ +#include + +int n, k, a[55], ans; + +int main() { + scanf("%d%d", &k, &n); + + for (int i = 1; i <= n; i++) { + scanf("%d", &a[i]); + } + + for (int i = 1; i <= n; i++) { + for (int j = 2; j <= n; j++) { + if (a[j] < a[j - 1]) { + int t = a[j]; + a[j] = a[j - 1]; + a[j - 1] = t; + } + } + } + + for (int i = 1; i <= n; i++) { + if (k > a[i]) { + k -= a[i]; + ans++; + } + } + + printf("%d\n", ans); + + return 0; +} diff --git a/【实践课外】7.数组1/7-12 数组-值钱的微信号.jpg b/【实践课外】7.数组1/7-12 数组-值钱的微信号.jpg new file mode 100644 index 0000000..a19b2a0 Binary files /dev/null and b/【实践课外】7.数组1/7-12 数组-值钱的微信号.jpg differ diff --git a/【实践课外】7.数组1/7-14 数组-吹泡泡.c b/【实践课外】7.数组1/7-14 数组-吹泡泡.c new file mode 100644 index 0000000..feca843 --- /dev/null +++ b/【实践课外】7.数组1/7-14 数组-吹泡泡.c @@ -0,0 +1,40 @@ +#include + +const double PI = 3.14; +const double FDT = 1.33; + +int n, id[1005]; +double v[1005]; + +int main() { + scanf("%d", &n); + + for (int i = 1; i <= n; i++) { + double r; + + scanf("%lf", &r); + + v[i] = FDT * PI * r * r * r; + id[i] = i; + } + + for (int i = 1; i <= n; i++) { + for (int j = 2; j <= n; j++) { + if (v[j] > v[j - 1] || (v[j] == v[j - 1] && id[j] < id[j - 1])) { + double t = v[j]; + v[j] = v[j - 1]; + v[j - 1] = t; + + int tt = id[j]; + id[j] = id[j - 1]; + id[j - 1] = tt; + } + } + } + + for (int i = 1; i <= n; i++) { + printf("%.2lf %d\n", v[i], id[i]); + } + + return 0; +} diff --git a/【实践课外】7.数组1/7-14 数组-吹泡泡.jpg b/【实践课外】7.数组1/7-14 数组-吹泡泡.jpg new file mode 100644 index 0000000..485a44c Binary files /dev/null and b/【实践课外】7.数组1/7-14 数组-吹泡泡.jpg differ diff --git a/【实践课外】7.数组1/7-19 数组-数学鬼才.c b/【实践课外】7.数组1/7-19 数组-数学鬼才.c new file mode 100644 index 0000000..5f28f5c --- /dev/null +++ b/【实践课外】7.数组1/7-19 数组-数学鬼才.c @@ -0,0 +1,27 @@ +#include + +int main() { + int q; + + scanf("%d", &q); + + while (q--) { + long long n; + + scanf("%lld", &n); + + if (n >= 2018) { + printf("0\n"); + } else { + int ans = 1; + + for (int i = 1; i <= n; i++) { + ans = (long long)ans * i % 2018; + } + + printf("%d\n", ans); + } + } + + return 0; +} diff --git a/【实践课外】7.数组1/7-19 数组-数学鬼才.jpg b/【实践课外】7.数组1/7-19 数组-数学鬼才.jpg new file mode 100644 index 0000000..3d327cc Binary files /dev/null and b/【实践课外】7.数组1/7-19 数组-数学鬼才.jpg differ diff --git a/【实践课外】7.数组1/7-5 计算最大值出现的次数.c b/【实践课外】7.数组1/7-5 计算最大值出现的次数.c new file mode 100644 index 0000000..c39c950 --- /dev/null +++ b/【实践课外】7.数组1/7-5 计算最大值出现的次数.c @@ -0,0 +1,31 @@ +#include + +int n, a[1005]; + +int main() { + scanf("%d", &n); + + for (int i = 1; i <= n; i++) { + scanf("%d", &a[i]); + } + + int max = a[0]; + + for (int i = 2; i <= n; i++) { + if (a[i] > max) { + max = a[i]; + } + } + + int count = 0; + + for (int i = 1; i <= n; i++) { + if (a[i] == max) { + count++; + } + } + + printf("%d %d\n", max, count); + + return 0; +} diff --git a/【实践课外】7.数组1/7-5 计算最大值出现的次数.jpg b/【实践课外】7.数组1/7-5 计算最大值出现的次数.jpg new file mode 100644 index 0000000..80cdd50 Binary files /dev/null and b/【实践课外】7.数组1/7-5 计算最大值出现的次数.jpg differ diff --git a/【实践课外】7.数组1/7-6 求一批整数中出现最多的个位数字.c b/【实践课外】7.数组1/7-6 求一批整数中出现最多的个位数字.c new file mode 100644 index 0000000..62bd5b8 --- /dev/null +++ b/【实践课外】7.数组1/7-6 求一批整数中出现最多的个位数字.c @@ -0,0 +1,54 @@ +#include + +int n, cnt[15]; + +int main() { + scanf("%d", &n); + + for (int i = 1; i <= n; i++) { + int x; + + scanf("%d", &x); + + if (x == 0) { + cnt[0]++; + } else { + while (x) { + cnt[x % 10]++; + x /= 10; + } + } + } + + int max = 0; + + for (int i = 0; i <= 9; i++) { + if (cnt[i] > max) { + max = cnt[i]; + } + } + + int max_cnt = 0, out_cnt = 0; + + for (int i = 0; i <= 9; i++) { + if (cnt[i] == max) { + max_cnt++; + } + } + + printf("%d: ", max); + + for (int i = 0; i <= 9; i++) { + if (cnt[i] == max) { + out_cnt++; + + if (out_cnt < max_cnt) { + printf("%d ", i); + } else { + printf("%d\n", i); + } + } + } + + return 0; +} diff --git a/【实践课外】7.数组1/7-6 求一批整数中出现最多的个位数字.jpg b/【实践课外】7.数组1/7-6 求一批整数中出现最多的个位数字.jpg new file mode 100644 index 0000000..ffcda68 Binary files /dev/null and b/【实践课外】7.数组1/7-6 求一批整数中出现最多的个位数字.jpg differ diff --git a/【实践课外】7.数组1/7-7 装箱问题.c b/【实践课外】7.数组1/7-7 装箱问题.c new file mode 100644 index 0000000..fc27b68 --- /dev/null +++ b/【实践课外】7.数组1/7-7 装箱问题.c @@ -0,0 +1,27 @@ +#include + +int n, box[1005]; + +int main() { + scanf("%d", &n); + + for (int i = 1; i <= n; i++) { + int x; + + scanf("%d", &x); + + for (int j = 1; j <= n; j++) { + if (box[j] + x <= 100) { + printf("%d %d\n", x, j); + box[j] += x; + break; + } + } + } + + while (box[n] == 0) n--; + + printf("%d\n", n); + + return 0; +} diff --git a/【实践课外】7.数组1/7-7 装箱问题.jpg b/【实践课外】7.数组1/7-7 装箱问题.jpg new file mode 100644 index 0000000..c729dea Binary files /dev/null and b/【实践课外】7.数组1/7-7 装箱问题.jpg differ