登录
首页 » c++ » 基于C语言的黄金分割法机械优化设计

基于C语言的黄金分割法机械优化设计

于 2022-01-24 发布 文件大小:86.05 kB
0 30
下载积分: 2 下载次数: 1

代码说明:

基于C语言的黄金分割法,以例题的形式很好地讲述了黄金分割法在一维搜索中的应用,重要的程序后面都有讲解,对于初学者来说学习起来会非常的方便,可以根据自己需要改变数据,按自己需求更改程序里面的数据,得到自己想要的结果。程序简单精炼,是一个非常不错的小程序。

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • C程序设计语言(第2版·新版)非扫描版
    说明:  c语言基础大全,内容丰富,知识点全,适合查漏补缺,内容广,不建议初学者深度学习。(C language has a large foundation, rich content and complete knowledge points. It is suitable for leak detection and vacancy filling. It has a wide range of contents. It is not recommended for beginners to learn in depth.)
    2020-06-21 18:40:01下载
    积分:1
  • Elevator
    4×10的电梯群控系统的仿真平台,可以模拟群控电梯的实时运行情况,并提供了可视化的界面,可以记录乘客的进出时间,总之,在研究电梯群控算法方面,是非常有用的软件。(4 × 10 of the elevator group control system simulation platform that can simulate the elevator group control of real-time operation, and provides a visualization interface, can record the entry and exit of passengers time, short, in the study elevator group control algorithm is very useful software.)
    2021-04-23 15:08:47下载
    积分:1
  • winform DataGridViewRowStyle 常见用法实例源码下载 有图
    DataGridViewRowStyle  核心用法 截图: 核心代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace TestDataGridViewRowStyle{ public partial class Form1 : Form { //定义两种行样式 private DataGridViewCellStyle m_RowStyleNormal; private DataGridViewCellStyle m_RowStyleAlternate; //成绩单DataTable private DataTable m_GradeTable; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.dgvGrade.AutoGenerateColumns = false; this.SetRowStyle(); this.BindData(); } /// /// 设置行样式 /// private void SetRowStyle() { //可根据需要设置更多样式属性,如字体、对齐、前景色、背景色等 this.m_RowStyleNormal = new DataGridViewCellStyle(); this.m_RowStyleNormal.BackColor = Color.LightBlue; this.m_RowStyleNormal.SelectionBackColor = Color.LightSteelBlue; this.m_RowStyleAlternate = new DataGridViewCellStyle(); this.m_RowStyleAlternate.BackColor = Color.LightGray; this.m_RowStyleAlternate.SelectionBackColor = Color.LightSlateGray; } /// /// 绑定数据 /// private void BindData() { //建立一个DataTable并填充数据,然后绑定到DataGridView控件上 m_GradeTable = new DataTable(); m_GradeTable.Columns.Add("Class", typeof(string)); m_GradeTable.Columns.Add("Name", typeof(string)); m_GradeTable.Columns.Add("Grade", typeof(int)); m_GradeTable.Rows.Add(new string[] { "Class1", "Jim", "89" }); m_GradeTable.Rows.Add(new string[] { "Class1", "Jack", "77" }); m_GradeTable.Rows.Add(new string[] { "Class1", "Bill", "91" }); m_GradeTable.Rows.Add(new string[] { "Class2", "Tom", "58" }); m_GradeTable.Rows.Add(new string[] { "Class2", "Rose", "95" }); m_GradeTable.Rows.Add(new string[] { "Class3", "Peter", "64" }); m_GradeTable.Rows.Add(new string[] { "Class3", "David", "82" }); m_GradeTable.Rows.Add(new string[] { "Class3", "Eric", "68" }); m_GradeTable.Rows.Add(new string[] { "Class3", "Lily", "79" }); this.bdsGrade.DataSource = m_GradeTable; } private void dgvDataTable_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { //在此对行样式进行设置 if (e.ColumnIndex == this.dgvGrade.Columns["ColumnClass"].Index)//根据班级设置行样式 { DataGridViewRow CurrentRow = this.dgvGrade.Rows[e.RowIndex]; CurrentRow.HeaderCell.Value = Convert.ToString(e.RowIndex 1);//显示行号,也可以设置成显示其他信息 //CurrentRow.HeaderCell.ToolTipText = "当前第" Convert.ToString(e.RowIndex 1) "行";//设置ToolTip信息 //以下为根据上一行内容判断所属组的效果 if (e.RowIndex == 0)//首行必须特殊处理,将其设置为常规样式 { CurrentRow.DefaultCellStyle = this.m_RowStyleNormal; } else { //判断和上一行是否属于同一个班级,如果是则设置相同样式,否则设置另一种样式 //需要定义两个DataGridViewCellStyle,用于交替显示,也可以根据需要隐藏一些和上一行重复的信息 //这里当两行是同一个班级时,将下一行的班级信息隐藏掉,选中时则显示班级信息 if (CurrentRow.Cells[e.ColumnIndex].Value != DBNull.Value && CurrentRow.Cells[e.ColumnIndex].Value != null && CurrentRow.Cells[e.ColumnIndex].Value.ToString() == this.dgvGrade.Rows[e.RowIndex - 1].Cells[e.ColumnIndex].Value.ToString()) { CurrentRow.DefaultCellStyle = this.dgvGrade.Rows[e.RowIndex - 1].DefaultCellStyle;//设置和上一行的样式相同 CurrentRow.Cells[e.ColumnIndex].Style.ForeColor = CurrentRow.DefaultCellStyle.BackColor;//用前景色隐藏信息 //如果需要选中时显示完整信息则注释该下面一行 //CurrentRow.Cells[e.ColumnIndex].Style.SelectionForeColor = CurrentRow.DefaultCellStyle.SelectionBackColor;//选中时也使前景色等于背景色,将文字隐藏掉 } else//当前行和上一行不属于同一个班级时 { if (this.dgvGrade.Rows[e.RowIndex - 1].DefaultCellStyle == this.m_RowStyleNormal)//根据上一行的样式设置当前行的样式 CurrentRow.DefaultCellStyle = this.m_RowStyleAlternate; else CurrentRow.DefaultCellStyle = this.m_RowStyleNormal; } }//if(e.RowIndex == 0) } else if (e.ColumnIndex == this.dgvGrade.Columns["ColumnGrade"].Index)//根据成绩设置单元格样式 { if (this.dgvGrade.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != DBNull.Value && Convert.ToInt32(this.dgvGrade.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) < 60)//对不及格的成绩设置特殊样式 { this.dgvGrade.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.ForeColor = Color.Red;//设置小于60的数字显示为红色 this.dgvGrade.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.SelectionForeColor = Color.Red; this.dgvGrade.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.Alignment = DataGridViewContentAlignment.MiddleRight; } } } //根据内容设置行标头 private void dgvDataTable_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { if (this.dgvGrade.Rows[e.RowIndex].Cells["ColumnGrade"].Value == DBNull.Value) return; int intGrade = Convert.ToInt32(this.dgvGrade.Rows[e.RowIndex].Cells["ColumnGrade"].Value);//获取成绩 Image RowIcon;//标头图标 string strToolTip;//提示信息 if (intGrade >= 90) { RowIcon = TestDataGridViewRowStyle.Properties.Resources.GradeA;//从资源文件中获取图片 strToolTip = "Grade A"; } else if (intGrade >= 80) { RowIcon = TestDataGridViewRowStyle.Properties.Resources.GradeB; strToolTip = "Grade B"; } else if (intGrade >= 70) { RowIcon = TestDataGridViewRowStyle.Properties.Resources.GradeC; strToolTip = "Grade C"; } else if (intGrade >= 60) { RowIcon = TestDataGridViewRowStyle.Properties.Resources.GradeD; strToolTip = "Grade D"; } else { RowIcon = TestDataGridViewRowStyle.Properties.Resources.GradeF; strToolTip = "Grade F"; } e.Graphics.DrawImage(RowIcon, e.RowBounds.Left this.dgvGrade.RowHeadersWidth - 20, e.RowBounds.Top 4, 16, 16);//绘制图标 this.dgvGrade.Rows[e.RowIndex].HeaderCell.ToolTipText = strToolTip;//设置提示信息 } private void dgvGrade_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.RowIndex >=0 && e.ColumnIndex == 2) { if (this.dgvGrade.Rows[e.RowIndex].Cells["ColumnGrade"].Value == DBNull.Value) return; int intGrade = Convert.ToInt32(this.dgvGrade.Rows[e.RowIndex].Cells["ColumnGrade"].Value); Image img; if (intGrade >= 90) { img = TestDataGridViewRowStyle.Properties.Resources.high; } else if (intGrade >= 80) { img = TestDataGridViewRowStyle.Properties.Resources.arrow; } else if (intGrade >= 70) { img = TestDataGridViewRowStyle.Properties.Resources.up; } else if (intGrade >= 60) { img = TestDataGridViewRowStyle.Properties.Resources.down; } else { img = TestDataGridViewRowStyle.Properties.Resources.low; } Rectangle newRect = new Rectangle(e.CellBounds.X 3, e.CellBounds.Y 5, e.CellBounds.Height - 15, e.CellBounds.Height - 12); using (Brush gridBrush = new SolidBrush(this.dgvGrade.GridColor), backColorBrush = new SolidBrush(e.CellStyle.BackColor)) { using (Pen gridLinePen = new Pen(gridBrush, 2)) { // Erase the cell. e.Graphics.FillRectangle(backColorBrush, e.CellBounds); //划线 Point p1 = new Point(e.CellBounds.Left e.CellBounds.Width, e.CellBounds.Top); Point p2 = new Point(e.CellBounds.Left e.CellBounds.Width, e.CellBounds.Top e.CellBounds.Height); Point p3 = new Point(e.CellBounds.Left, e.CellBounds.Top e.CellBounds.Height); Point[] ps = new Point[] { p1, p2, p3 }; e.Graphics.DrawLines(gridLinePen, ps); //画图标 e.Graphics.DrawImage(img, newRect); //画字符串 e.Graphics.DrawString(intGrade.ToString(), e.CellStyle.Font, Brushes.Crimson, e.CellBounds.Left 20, e.CellBounds.Top 5, StringFormat.GenericDefault); e.Handled = true; } } } } }}
    2014-08-29下载
    积分:1
  • Hospital_MIS
    cs开发的一个医院管理系统,供学习和研究。(cs development of a hospital management system for learning and research.)
    2009-09-29 11:01:16下载
    积分:1
  • moxing
    说明:  地震资料处理中需要建立模型,这里上传了一个十分重要的地震资料双曲模型,利用雷克子波与反射系数乘积得到合成地震记录曲线,从而为下一步的处理做好准备。(The need for seismic data processing model, where a very important uploaded hyperbolic model of seismic data using wavelet Lake product obtained with the reflection coefficient curve of synthetic seismogram in order to be prepared to deal with the next step.)
    2021-03-16 16:19:22下载
    积分:1
  • Node2
    A test to measure temperature and the concentration of gases
    2015-05-13 21:08:55下载
    积分:1
  • LCD
    stm32液晶屏代码,通过按键使液晶屏显示的内容上下左右移动(Stm32 LCD code, through the buttons to make the content of the LCD display top to bottom and move around)
    2015-05-17 22:29:03下载
    积分:1
  • fangkuai2
    俄罗斯方块,用VC6.0写的,使用小键盘的2,8,4,6实现移动和变化,5暂停(Tetris with VC6.0 written using the keypad 2,8,4,6 for mobile and change, 5 suspended)
    2013-11-12 22:32:00下载
    积分:1
  • rdesktop多UI接口源码1.83版本
    rdesktop多UI接口源码,使用rdp协议实现,源码结构清晰易读,适合剖析学习
    2022-01-28 13:01:09下载
    积分:1
  • 100T2
    汽车横、轨道衡,电子汽车衡技术协议说明文档资料(Automotive Wang, railroad track scale, electronic truck scale information technology agreement documentation)
    2007-08-21 22:00:52下载
    积分:1
  • 696518资源总数
  • 104224会员总数
  • 54今日下载