之前以为BinaryWriter写string会严格按构造时指定的编码(不指定则是无BOM的UTF8)写入string的二进制,如下面的代码: //将字符串"a"写入流,再拿到流的字节组data using (var ms = new MemoryStream()) { using (var bw = new BinaryWriter(ms)) { bw.Write("a"); } byte[] data = ms.ToArray(); } 因为字母a的utf8编码
一道华三面试题,随机生成长度为len的密码,且包括大写.小写英文字母和数字,主要Random类的使用,random.nextInt(len)表示生成[0,len)整数.具体实现见下面代码,已经很详细了. package TestProject; import java.util.Random; import java.util.Scanner; /** * 随机生成长度为len的密码,且包括大写.小写英文字母和数字 * @author xuhui */ public class Main { s
1.替换字符串,即将某一字符串中的特定字符或字符串替换为给定的字符串.举例说明其功能:========================================= @echo off set aa=伟大的中国!我为你自豪! echo 替换前:%aa% echo 替换后:%aa:中国=中华人民共和国% echo aa = %aa% set "aa=%aa:中国=中华人民共和国%" echo aa = %aa% pause ==============================
Given a non-empty string, encode the string such that its encoded length is the shortest. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note: k will be a positive integ
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case letters. If no such two words exist, return 0. Example
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is defined as a character sequence consists of non-space cha