diff --git a/src/SUMMARY.md b/src/SUMMARY.md index ac7d29cf3..f03d68697 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -391,6 +391,7 @@ - [矩形相交的面积 - 数学](od/2024e100/area-of-intersected-rectangles/index.md) - [水仙花数I - 数学](od/2024e100/number-of-daffodil/index.md) - [不等式是否满足约束并输出最大差](od/2024e100/constraint-of-inequality/index.md) + - [字符统计及重排 - 字符串](od/2024e100/rearrange-chars/index.md) - [VLAN资源池](od/2024e100/vlan/index.md) - [OD 2024年E卷200分](od/2024e200/index.md) - [空栈压数](od/2024e200/push-numbers-into-stack/index.md) diff --git a/src/od/2024e100/index.md b/src/od/2024e100/index.md index 598917444..865c13372 100644 --- a/src/od/2024e100/index.md +++ b/src/od/2024e100/index.md @@ -49,4 +49,5 @@ 47. [矩形相交的面积 - 数学](area-of-intersected-rectangles/index.md) 48. [水仙花数I - 数学](number-of-daffodil/index.md) 49. [不等式是否满足约束并输出最大差](constraint-of-inequality/index.md) -50. [VLAN资源池](vlan/index.md) +50. [字符统计及重排 - 字符串](rearrange-chars/index.md) +51. [VLAN资源池](vlan/index.md) diff --git a/src/od/2024e100/rearrange-chars/Cargo.toml b/src/od/2024e100/rearrange-chars/Cargo.toml new file mode 100644 index 000000000..b429c159d --- /dev/null +++ b/src/od/2024e100/rearrange-chars/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "e100-rearrange-chars" +version = "0.1.0" +edition = "2021" +publish = false + +[dependencies] diff --git a/src/od/2024e100/rearrange-chars/assets/input1.txt b/src/od/2024e100/rearrange-chars/assets/input1.txt new file mode 100644 index 000000000..d86fd1fa6 --- /dev/null +++ b/src/od/2024e100/rearrange-chars/assets/input1.txt @@ -0,0 +1 @@ +xyxyXX \ No newline at end of file diff --git a/src/od/2024e100/rearrange-chars/assets/input2.txt b/src/od/2024e100/rearrange-chars/assets/input2.txt new file mode 100644 index 000000000..9867da1dc --- /dev/null +++ b/src/od/2024e100/rearrange-chars/assets/input2.txt @@ -0,0 +1 @@ +abababb \ No newline at end of file diff --git a/src/od/2024e100/rearrange-chars/assets/output1.txt b/src/od/2024e100/rearrange-chars/assets/output1.txt new file mode 100644 index 000000000..3be35e16c --- /dev/null +++ b/src/od/2024e100/rearrange-chars/assets/output1.txt @@ -0,0 +1 @@ +x:2;y:2;X:2; \ No newline at end of file diff --git a/src/od/2024e100/rearrange-chars/assets/output2.txt b/src/od/2024e100/rearrange-chars/assets/output2.txt new file mode 100644 index 000000000..23e5a9e2f --- /dev/null +++ b/src/od/2024e100/rearrange-chars/assets/output2.txt @@ -0,0 +1 @@ +b:4;a:3; \ No newline at end of file diff --git a/src/od/2024e100/rearrange-chars/index.md b/src/od/2024e100/rearrange-chars/index.md new file mode 100644 index 000000000..8941d32b4 --- /dev/null +++ b/src/od/2024e100/rearrange-chars/index.md @@ -0,0 +1,51 @@ +# 字符统计及重排 + +## 题目描述 + +给出一个仅包含字母的字符串, 不包含空格, 统计字符串中各个字母(区分大小写)出现的次数, + +并按照字母出现次数从大到小的顺序. 输出各个字母及其出现次数. + +如果次数相同, 按照自然顺序进行排序, 且小写字母在大写字母之前. + +### 输入描述 + +输入一行, 为一个仅包含字母的字符串. + +### 输出描述 + +按照字母出现次数从大到小的顺序输出各个字母和字母次数, 用英文分号分隔, 注意末尾的分号. + +字母和次数间用英文冒号分隔. + +### 示例1 + +输入: + +```text +{{#include assets/input1.txt}} +``` + +输出: + +```text +{{#include assets/output1.txt}} +``` + +### 示例2 + +输入: + +```text +{{#include assets/input2.txt}} +``` + +输出: + +```text +{{#include assets/output2.txt}} +``` + +说明: b的出现个数比a多,故b排在a之前 + +## 题解 diff --git a/src/od/2024e100/rearrange-chars/src/main.rs b/src/od/2024e100/rearrange-chars/src/main.rs new file mode 100644 index 000000000..e7a11a969 --- /dev/null +++ b/src/od/2024e100/rearrange-chars/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}