chen0adapter
chen0adapter
全部文章
题解
归档
标签
去牛客网
登录
/
注册
林中书屋
道本无名,我亦无名
全部文章
/ 题解
(共60篇)
题解 | #密码强度等级#
来自专栏
解题思路: 依次判断条件并将结果存入总分数score中,由于rust中的char类型的is_ascii_digit()、is_ascii_uppercase()、is_ascii_lowercase()、is_ascii_punctuation() 四个函数可以分别用来判断数字、大小写和字符,所以...
Rust
2022-05-30
0
414
题解 | #百钱买百鸡问题#
来自专栏
打表: use std::io; fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).expect("Failed To Read Line !"); print!("0 25 ...
Rust
2022-05-24
0
342
题解 | #高精度整数加法#
来自专栏
解题思路: 将两个字符串转化为u8数组,比较两者长度后先按较短者长度加和,若较长者中还有剩余数组,再进行加和判断,最后判断进位re是否还为1。 将加和结果存储在v_3数组中,最后倒序输出数组即可。 use std::{io, cmp::Ordering}; fn main() { le...
Rust
2022-05-23
0
334
题解 | #查找输入整数二进制中1的个数#
来自专栏
use std::io::{self, *}; fn main() { let stdin = io::stdin(); for line in stdin.lock().lines() { println!("{}",line.unwrap().trim().par...
Rust
2022-05-14
0
312
题解 | #扑克牌大小#
来自专栏
解题思路: 由于扑克牌大小顺序不按照字典序,所以按顺序存在数组里,当需要比较的时候,比一下位置先后就可以了 use std::io; fn compare(l: &str, r: &str) -> bool { let order = ["3", "4", "5", ...
Rust
2022-05-10
0
355
题解 | #求最大连续bit数#
来自专栏
解题思路 直接转成二进制字符串,再判断最长连续1。 use std::io::{self, *}; fn main() { let stdin = io::stdin(); for line in stdin.lock().lines() { let ll = l...
Rust
2022-05-09
0
359
题解 | #合法IP#
来自专栏
解题思路: 按*切割为数组,其长度不等于4,不是IPV4 某个元素+开头,不是IPV4 某个元素0开头却长度大于1,不是IPV4 以下代码中多次用到match,是为了清晰地表示以上判断。 use std::io::{self, *}; fn main() { let stdin ...
Rust
2022-05-08
0
429
题解 | #在字符串中找出连续最长的数字串#
来自专栏
解题思路: 将字符串转换为u8数组v,再将数字串给转存到另一个数组m中,排序后输出。 use std::io::{self, *}; fn main() { let stdin = io::stdin(); for line in stdin.lock().lines() { ...
Rust
2022-05-08
0
429
题解 | #统计大写字母个数#
来自专栏
use std::io; fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); let mut count = 0u8; for &i in s....
Rust
2022-05-07
0
282
题解 | #走方格的方案数#
来自专栏
两种方法: 1、递归 2、动态规划 rust rust use std::io; pub fn calc(i: u32, j: u32, n: u32, m: u32) -> u32 { if i == n || j == m { return 1; ...
Rust
2022-05-07
0
336
首页
上一页
1
2
3
4
5
6
下一页
末页