public static string CreateRegionCode(int strlength)
{
//定义一个字符串数组储存汉字编码的组成元素
string[] rBase = new String[16] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
Random rnd = new Random();
string rest = "";
Encoding encoding = Encoding.GetEncoding("GB2312");
/**/
/*每循环一次产生一个含两个元素的十六进制字节数组,并将其放入bject数组中
每个汉字有四个区位码组成
区位码第1位和区位码第2位作为字节数组第一个元素
区位码第3位和区位码第4位作为字节数组第二个元素
*/
for (int i = 0; i < strlength; i++)
{
//区位码第1位
int r1 = rnd.Next(11, 14);
string str_r1 = rBase[r1].Trim();
//区位码第2位
rnd = new Random(r1 * unchecked((int)DateTime.Now.Ticks) + i);//更换随机数发生器的种子避免产生重复值
int r2;
if (r1 == 13)
{
r2 = rnd.Next(0, 7);
}
else
{
r2 = rnd.Next(0, 16);
}
string str_r2 = rBase[r2].Trim();
//区位码第3位
rnd = new Random(r2 * unchecked((int)DateTime.Now.Ticks) + i);
int r3 = rnd.Next(10, 16);
string str_r3 = rBase[r3].Trim();
//区位码第4位
rnd = new Random(r3 * unchecked((int)DateTime.Now.Ticks) + i);
int r4;
if (r3 == 10)
{
r4 = rnd.Next(1, 16);
}
else if (r3 == 15)
{
r4 = rnd.Next(0, 15);
}
else
{
r4 = rnd.Next(0, 16);
}
string str_r4 = rBase[r4].Trim();
//定义两个字节变量存储产生的随机汉字区位码
byte byte1 = Convert.ToByte(str_r1 + str_r2, 16);
byte byte2 = Convert.ToByte(str_r3 + str_r4, 16);
//将两个字节变量存储在字节数组中
byte[] str_r = new byte[] { byte1, byte2 };
//将产生的一个汉字的字节数组放入object数组中
rest += encoding.GetString(str_r);
}
return rest;
}相关推荐
思科华三设备组网思科生成树PVST发BPDU导致全网闪断
一、故障现象 1.思科PVST BPDU报文导致全网闪断。 2.光衰低时不同品牌网络设备无法兼容导致接入交换机中断。 二、网络拓扑 图1 网络拓扑图 组网结构为H3C汇聚,接入交换机有思科,也有H3C,而且与汇聚直连的接入交换机下面串接了较多的交换机,或者hub。 三、排查思路 1.回忆一下最近做了什么事情,什么时候开始出的问题。 将网络汇聚交换机从思科换为H3C,H3C汇聚和思科接入对接出问题...
C 关于中文汉字字符串
int main() { int str="哈哈哈哈哈";//是int不是char printf("%s\n",str);//是%s不是%c }
互联网金融项目实战(大数据Hadoop hive)
什么是互联网金融? 互联网金融 --> 信贷(信用贷款) --> 支付宝率先搞了一个信用体系 互联网金融: 在线支付、P2P 银行: 只会锦上添画、不喜欢雪中送炭 银行害怕出现坏账 ( 储户存钱,银行放贷 赚个利息差 ) 银行是可以倒闭的 保险公司不允许倒闭 银行分为:商业银行(自生自灭的)和非商业银行(国家的) 中国工商银行 全球第一大行 招商银行(清朝的一个李鸿章) 中国银行(历史超过 100 年了) 国家政策:希望银行能够扶持中小型企业 p2p:网络借贷平台 民间吸纳贷款 -->
01-程序员必备:彻底弄懂常见的7种中文字符编码
例如你把UTF8编码的“讯”字(UTF8编码为0xE8AEAF,占三个字节)存入了Latin1编码的Mysql表,那么在Mysql眼里,你存入的并不是一个“讯”字,而是三个Latin1的字母(0xE8,0xAE,0xAF)。ASCII编码由于是单字节,所以没有第2位。第2件事情通常解决方案要么就是规定好每个字长度(例如所有文字都是2bytes,不够的前面用0补齐),要么就是在用0和1表示的时候,不仅需要表示出数字编码,还要暗示给计算机接下来多少个连续byte构成一个字,这个后面UTF8编码中会提到。
同花顺Supermind量化交易 风险控制建模--海龟交易法则
A.市场与标的海龟交易法则应用于流动性高的市场中,选择交易量较大的标的进行交易。本文以沪深300指数ETF为标的,构建海龟交易法则。B、仓位:仓位是海龟交易系统最核心的部分,通过ATR真实波幅指标来管理仓位。第一步:计算True Range,简称TR。TR = Max ( H−L , H−P , P−L ) ,其中H为当日日内最高价,L为当日日内最低价,P为前一日收盘价。第二步:计算ATRATR = mean ( TR , 20 ) , 即计算过去20天的TR的平均值,ATR是TR的移动平均值。
rk3576 适配以太网(百兆)
百兆以太网,也常被称为快速以太网,是一种在1990年代中期推出的计算机网络技术标准。它相当于把当时主流的10兆以太网速度提升了10倍,最高能提供 100 Mbps 的传输速率,让文件共享、视频传输等网络应用变得流畅许多。它在数据链路层面完全保留了传统以太网的帧格式和MAC机制,这意味着现有的网络软件可以无缝对接,用户从10兆网络升级到百兆网络时,通常只需要更换网卡和集线器/交换机即可,非常方便。 在rk3576平台上,原生以太网接口支持百兆、千兆,还有pcie转换的2.5G。
将汉字转为字符串
import java.util.Arrays; public class Num2Rmb { private String[] hanArr = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" }; private String[] unitArr = { "千", "百", "十" }; // 价格数字分割为整数部分与小数部分 p
人群仿真软件:AnyLogic_(12).AnyLogic高级功能应用
在AnyLogic中,自定义行人行为是通过编写Java代码来实现的。行人行为的自定义可以包括行走路径的选择、速度变化、交互行为等。这使得仿真模型更加灵活和真实。
生成随机数量的中文字符串
生成随机长度中文的两种方法。
03 Token、Embedding、上下文窗口:开发者必须懂的三个基本概念
Token、Embedding 和上下文窗口是大模型应用开发的三个基础概念。本文从成本、速度、检索和上下文设计四个角度讲清它们的工程意义,帮助开发者理解为什么同一段内容会超限、变贵,为什么 RAG 能做语义检索。
把 MCP Server 直接装进 SAP ABAP:用 Unlimited Display Tools 打通 Agentic SDK 与 SAP ECC / S/4HANA 的最后一公里
摘要:AI与SAP集成的MCP解决方案 企业在AI集成中面临工具链复杂、数据对接繁琐的挑战。Model Context Protocol (MCP)通过标准化工具与数据暴露方式,将集成复杂度从N×M降至N+M。在SAP生态中,MCP Server for SAP直接部署于ABAP层,利用DDIC/CDS视图对接各类Agent SDK,避免中间件风险。 MCP核心包含三类对象: Tools:带元数据的可执行动作 Resources:结构化上下文数据 Prompts:可参数化提示模板 ABAP层实现MCP Se
中文字符转换
从数据库读取‘name’,然后转换成中文字符。byte[] b = rs.getString("name").getBytes("ISO8859_1");String name = new String(b,"gb2312");转载:/** * 用getBytes(encoding):返回字符串的一个byte数组 * 当b[0]为 63时,应该是转码错
46、大数据助力SDN优化流量管理与控制器
本文探讨了大数据在软件定义网络(SDN)中的应用,重点分析了如何利用大数据技术优化SDN控制器的可扩展性和弹性。通过介绍SDN控制器的核心功能及其面临的挑战,提出了集中式、分布式、混合式和分层式控制器放置策略,并结合大数据分析系统架构与技术,详细阐述了在控制器放置优化、流聚合和备份路径识别等场景中的实际应用。文章还给出了大数据分析在SDN控制器优化中的操作流程与优势,展望了未来结合人工智能与物联网的发展方向,强调了数据安全与算法效率的重要性。
c#生成随机位数的汉字字符串
今天在网上查了下如何生成随机汉字字符串的方法,现在一起分享供大家学习和参考。 public string aa() { Encoding gb = Encoding.GetEncoding("gb2312"); //调用函数产生4个随机中文汉字编码 object[] bytes = CreateRegionCode
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
Camera2Demo
在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作
php随机生成汉字、随机字符串
// $num为生成汉字的数量 function getChar($num){ $b = ''; for ($i=0; $i<$num; $i++) { // 使用chr()函数拼接双字节汉字,前一个chr()为高位字节,后一个为低位字节 $a = chr(mt_rand(0xB0,0xD0)).chr(mt_rand(0xA1, 0xF0))......
精雕软件(JDpaint) 5.5 绿色版
精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版
生成随机汉字字符串
【代码】生成随机汉字字符串。
vb 6.0并口开发操作实例
vb6并口开发,简体中文,试例内有inpout32.dll动态链接库
Java随机生成汉字
Java随机生成汉字
生成各种随机数据:随机数、随机字符串、随机汉字姓名、随机电话号码、随机日期
示例1:产生随机数 public static void main(String[] args) { // 产生随机三位整数[100,999] // 方式一: // Math.random()产生随机[m,n]整数的公式:Math.random()*(n-m+1)+m for (int i = 0; i < 10; i++) { int digit = (int) (Math.r...
简单实现 随机产生一段汉字
今天公司突然需要这个 简单实现 随机产生一段汉字,直接上源码。 //汉子有两个字节组成 string GetRandomCNStringByLongth(int longth) { srand((unsigned)time(NULL)); int iRange1 = 0xf7 - 0xb0; int iRange2 = 0xfe - 0xa1; char cnStr
java汉字工具类(java随机生成一个或多个汉字)
/** * 汉字工具类 * @ClassName HanZiUtil * @Description * @Author liuFuTao * @Date 2020/6/16 10:56 */ public class HanZiUtil { /** * 返回一个汉字 * @param * @return */ public static char getRandomHanZi() { return (char) (0x4e0.
php生成随机汉字,PHP生成随机中文字符串
function unicode_decode($name) {// 转换编码,将Unicode编码转换成可以浏览的utf-8编码$pattern = '/([\w]+)|(\\\u([\w]{4}))/i';preg_match_all($pattern, $name, $matches);if (!empty($matches)) {$name = '';for ($j = 0; $j <...
用java随机输出汉字
package com.leo.demo; import java.util.Random; /** * 打印随机的汉字 * * @author Administrator * */ public class Charactor { public static void main(String[] args) { // 常用汉字集 String base = "\u76
java生成随机汉字_JAVA如何随机生成一个汉字
package com.test;import java.math.BigDecimal;import java.math.RoundingMode;import java.util.Random;/*** @author QiaoJiafei* @version 创建时间:2015年12月21日 下午2:53:44* 类说明*/public class TestSiSheWuRu {public...
grovvy生成随机汉字名字
StringBuilder sb = new StringBuilder(); for(int i = 0 ;i < 3; i++){ sb.append((char) (0x4e00 + (int) (Math.random() * (0x9fa5 - 0x4e00 + 1)))); } vars.put("name",sb.toStr...
php生成随机汉字,php生成随机字符串函数(支持字母大小写,数字,中文)
[php]代码库/**+----------------------------------------------------------* 产生随机字串, 可用来自动生成密码,验证码,表单令牌等* 默认长度6位 字母和数字混合 支持中文+----------------------------------------------------------* @param string $len ...
JAVA随机字符串
package Strings;import java.util.Random; import java.util.UUID;public class 随机字符 { public static void main(String[] args) { String uuid = UUID.randomUUID().toString().replace("-", "");
7548



被折叠的 条评论
为什么被折叠?



