chestnuts同志!我来做好事,你公布源码吧!

csharpsharper 2003-02-10 11:22:09
见上
...全文
41 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxj 2003-03-17
  • 打赏
  • 举报
回复
做的已经很好!
但是:
1、不区分关键词是否在字符串内的,每一种开发语言认为字符串都不一样
2、若关键词包含两个单词时:如:SQL 中的关键词 order by,
我输入ORDER BY (中间含有多个空格或者换行,就有问题)

chestnuts 2003-02-10
  • 打赏
  • 举报
回复
好!
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication10
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private int bootIndex=0;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Panel panel2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//

}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// richTextBox1
//
this.richTextBox1.AutoSize = true;
this.richTextBox1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.RightMargin = 100;
this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedHorizontal;
this.richTextBox1.Size = new System.Drawing.Size(448, 308);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "well well";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 16);
this.button1.Name = "button1";
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(16, 16);
this.button2.Name = "button2";
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// panel1
//
this.panel1.Location = new System.Drawing.Point(400, 248);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(16, 16);
this.panel1.TabIndex = 4;
this.panel1.Visible = false;
//
// label2
//
this.label2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(128)), ((System.Byte)(0)));
this.label2.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.label2.Location = new System.Drawing.Point(80, 240);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(296, 16);
this.label2.TabIndex = 5;
this.label2.Text = "the Key:\"me\",\"you\",\"and\",\"Lucy\",\"hehui\",\"heli\"";
//
// panel2
//
this.panel2.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.panel2.AutoScroll = true;
this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] {
this.richTextBox1});
this.panel2.Location = new System.Drawing.Point(0, 48);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(448, 308);
this.panel2.TabIndex = 6;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(448, 358);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.panel2,
this.label2,
this.panel1,
this.button2,
this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
this.richTextBox1.SaveFile("e:/12.rtf");
}

private void button2_Click(object sender, System.EventArgs e)
{
this.richTextBox1.SelectionColor=Color.Red;
}

private void richTextBox1_TextChanged(object sender, System.EventArgs e)
{
this.panel1.Select();
this.richTextBox1.HideSelection=true;
AllLines();
this.richTextBox1.Focus();
}

private void Form1_Load(object sender, System.EventArgs e)
{

}
private void AllLines()
{
String[] key={"me","you","and","Lucy","hehui","heli"};
bootIndex=this.richTextBox1.SelectionStart;
this.richTextBox1.SelectAll();
this.richTextBox1.SelectionColor=Color.Black;
this.richTextBox1.Select(bootIndex,0);
int length=this.richTextBox1.TextLength;
foreach(string keyword in key)
{
int start=this.richTextBox1.Find(keyword,RichTextBoxFinds.WholeWord|RichTextBoxFinds.NoHighlight);
while(start!=-1)
{
this.richTextBox1.Select(start,keyword.Length);
this.richTextBox1.SelectionColor=Color.Red;
this.richTextBox1.Select(start+keyword.Length,1);
this.richTextBox1.SelectionColor=Color.Black;
start=this.richTextBox1.Find(keyword,start+keyword.Length,RichTextBoxFinds.WholeWord|RichTextBoxFinds.NoHighlight);
if(start+keyword.Length>=length)//如果是最后打的的解决办法
{
this.richTextBox1.Select(start,keyword.Length);
this.richTextBox1.SelectionColor=Color.Red;
this.richTextBox1.Select(start+keyword.Length,0);
this.richTextBox1.SelectionColor=Color.Black;
break;
}

}
}
this.richTextBox1.Select(bootIndex,0);
}

}
}
内容概要:本文系统研究了电力系统短期负荷预测问题,提出并实现了基于极限学习机(ELM)及其智能优化改进模型的预测方法。研究涵盖标准ELM、白鲸优化算法(BWO)优化ELM和鹭鹰优化算法(IBOA)优化ELM三种模型,重点通过智能优化算法对ELM的输入权重与偏置参数进行全局寻优,有效克服了传统ELM因参数随机初始化导致的不稳定性和泛化能力不足的问题。文章完整呈现了从数据预处理、特征选择、模型构建、参数优化到预测结果对比分析的全流程,利用Matlab编程实现各模型的仿真验证,显著提升了预测精度与模型鲁棒性,为电力系统调度决策提供了可靠的技术支撑。; 适合人群:具备电力系统基础知识、时间序列预测理论及Matlab编程能力的高校研究生、科研机构研究人员以及电力公司从事负荷预测、电网调度与规划工作的技术人员。; 使用场景及目标:①应用于实际电力系统短期负荷预测业务中,提升电网运行调度的精细化与智能化水平;②作为智能优化算法与神经网络融合的经典案例,服务于学术论文撰写、科研项目申报及算法性能对比研究;③应对新能源大规模接入背景下负荷波动加剧的挑战,为构建高精度、强鲁棒性的现代负荷预测体系提供解决方案。; 阅读建议:建议读者结合所提供的Matlab代码进行动手实践,深入理解ELM网络结构与优化算法的集成机制,重点对比分析不同优化策略在收敛速度、预测误差(如MAE、RMSE、MAPE)等方面的性能差异,进而掌握智能优化技术在提升预测模型性能方面的关键作用。

111,131

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧