Skip to content

Commit

Permalink
e100: Add rearrange chars
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua committed Sep 18, 2024
1 parent f6f5706 commit 9d7c759
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/od/2024e100/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 7 additions & 0 deletions src/od/2024e100/rearrange-chars/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "e100-rearrange-chars"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
1 change: 1 addition & 0 deletions src/od/2024e100/rearrange-chars/assets/input1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xyxyXX
1 change: 1 addition & 0 deletions src/od/2024e100/rearrange-chars/assets/input2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
abababb
1 change: 1 addition & 0 deletions src/od/2024e100/rearrange-chars/assets/output1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x:2;y:2;X:2;
1 change: 1 addition & 0 deletions src/od/2024e100/rearrange-chars/assets/output2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b:4;a:3;
51 changes: 51 additions & 0 deletions src/od/2024e100/rearrange-chars/index.md
Original file line number Diff line number Diff line change
@@ -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之前

## 题解
3 changes: 3 additions & 0 deletions src/od/2024e100/rearrange-chars/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

0 comments on commit 9d7c759

Please sign in to comment.