02 2013 档案

摘要:1、实现一个函数,对一个正整数n,算得到1需要的最少操作次数。操作规则为:如果n为偶数,将其除以2;如果n为奇数,可以加1或减1;一直处理下去。例子:func(7) = 4,可以证明最少需要4次运算n = 7n-1 6n/2 3n-1 2n/2 1要求:实现函数(实现尽可能高效) int func(unsign int n);n为输入,返回最小的运算次数。给出思路(文字描述),完成代码,并分析你算法的时间复杂度。答:[cpp]view plaincopyintfunc(unsignedintn){if(n==1)return0;if(n%2==0)return1+func(n/2);intx= 阅读全文
posted @ 2013-02-27 16:32 蓬莱仙羽 阅读(205) 评论(0) 推荐(0)
摘要:1、html基本结构<html><head><title>我的第一个网页</title></head><body bgcolor="red" background="bg.jpg"></body></html>2、文本相关标签<H1> - <H6><font> color size face<p> align <br><center> <b> <i><hr&g 阅读全文
posted @ 2013-02-26 20:14 蓬莱仙羽 阅读(183) 评论(0) 推荐(0)
摘要:如何实现语音和朗诵的功能:using System;using System.Windows.Forms;using System.IO;using System.Media;using System.Runtime.InteropServices;namespace 播放TTS{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } //根目录 string address = System.AppDomain.CurrentDomain.BaseDirectory; private voi 阅读全文
posted @ 2013-02-24 21:20 蓬莱仙羽 阅读(206) 评论(0) 推荐(0)
摘要:如何添加数据库中的信息加载到树形控件中?如何遍历控件中的信息?如何对控件中的信息进行增删查改?数据库设计:主界面:代码:using System;using System.Collections.Generic;using System.Windows.Forms;using TreeSolution.BLL;using TreeSolution.Model;namespace 树型测试{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } //当窗体加载时,加载树形节点 private v 阅读全文
posted @ 2013-02-22 11:33 蓬莱仙羽 阅读(234) 评论(0) 推荐(0)
摘要:Winform特有的功能如何保存当前窗口中所填的信息,方便下次打开 还是这样的,实现如下:首先,在当前项目中打开Properties——Settings.settings,然后点击,添加字段;其次,再点击界面中控件的属性,然后选择ApplicationSettings属性,选Text属性,选择刚刚设置的字段最后,用一个事件来实现数据保存,代码:Settings.Default.Save();实现了需要的功能 阅读全文
posted @ 2013-02-21 16:49 蓬莱仙羽 阅读(353) 评论(0) 推荐(0)
摘要:using System;using System.Windows.Forms;namespace TreeView控件{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { treeView1.Nodes.Clear(); //每一个节点都是一个TreeNode的一个对象 TreeNode nodeChina = new TreeNode(); nodeChina.Text = 阅读全文
posted @ 2013-02-20 22:31 蓬莱仙羽 阅读(147) 评论(0) 推荐(0)
摘要:/// <summary> /// 复合查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCheck_Click(object sender, EventArgs e) { //方法一 //StringBuilder sb = new StringBuilder(); //sb.Append("select * from T_Cus 阅读全文
posted @ 2013-02-20 16:30 蓬莱仙羽 阅读(162) 评论(0) 推荐(0)
摘要:项目命名规则:方法名首字母大写,参数名、变量名第一个字母小写,其它字母大写。//驼峰命名法ViewBag后面单词大写。千万不要在循环访问数据库。数据能一次取出来就一次取出来。放到内在中处理。MVC中保持状态可以用ViewBag来保存。问题1、ajax重复提交问题:JS动态创建html时.有时候 \" 和'不一样。用log 记录日志的时候一般都是记录关键的步骤。空格 在IE和firfox 解析不一样。切记document.getElementById('').getElementsByTagName("a");这样在IE里面可以解析,但是在火 阅读全文
posted @ 2013-02-20 10:43 蓬莱仙羽 阅读(118) 评论(0) 推荐(0)
摘要:当我们遇到要处理汉字和拼音之间的转化关系怎么办?如和用程序来实现?我搜索到一个ChineseChar开发包,然后实现了这一难题using System;using Microsoft.International.Converters.PinYinConverter;namespace 拼音基础{ class Program { static void Main(string[] args) { #region 判断是否为同音字 ChineseChar chineseChar = new ChineseChar('微'); Console.WriteLine("Stro 阅读全文
posted @ 2013-02-19 14:55 蓬莱仙羽 阅读(210) 评论(0) 推荐(0)
摘要:using System;using System.Windows.Forms;using System.Security.Cryptography;using System.IO;namespace 计算文件的MD5{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //创建与服务器的连接 FtpClient fc = new FtpClient("127.0.0 阅读全文
posted @ 2013-02-17 21:27 蓬莱仙羽 阅读(528) 评论(0) 推荐(0)
摘要://FTP开源封装的类using System;using System.Collections.Generic;using System.Net;using System.IO;namespace FTP{ /// <summary> /// FTP客户端操作类 /// </summary> public class FtpClient { #region 构造函数 /// <summary> /// 创建FTP工具 /// <para> /// 默认不使用SSL,使用二进制传输方式,使用被动模式 /// </para> /// & 阅读全文
posted @ 2013-02-16 21:30 蓬莱仙羽 阅读(1051) 评论(0) 推荐(0)
摘要:C#操作Excel,如果格式是xlsx的就用openXML来操作,如果是xls的就用NPOI来操作应该讲第三方组件,单独存在一个lib文件夹中,然后添加引用,这样组件就能随着项目走xlsx实际上是一个压缩文件using System;using System.Windows.Forms;using System.IO;using NPOI.HSSF.UserModel;namespace NPOI测试{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } /// <summary> 阅读全文
posted @ 2013-02-05 16:00 蓬莱仙羽 阅读(646) 评论(0) 推荐(0)
摘要:using System;using System.Text.RegularExpressions;using System.Net;namespace 正则表达式检测字符串{ class Program { static void Main(string[] args) { Console.WriteLine("请输入字符串:"); string s = Console.ReadLine(); if (GF_IsOk.IsExistHanZi(s)) { Console.Write("包含汉字"); } else { Console.Write(&qu 阅读全文
posted @ 2013-02-05 14:51 蓬莱仙羽 阅读(240) 评论(0) 推荐(0)
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf- 阅读全文
posted @ 2013-02-04 16:34 蓬莱仙羽 阅读(161) 评论(0) 推荐(0)
摘要:object missing =System.Reflection.Missing.Value; ApplicationClass app = newApplicationClass(); app.SheetsInNewWorkbook = 1; app.Visible = true; Workbook wb =app.Workbooks.Add(XlWBATemplate.xlWBATWorksheet); Worksheet sheet =(Worksheet)wb.Sheets[1]; sheet.get_Range("A1","A1").Valu 阅读全文
posted @ 2013-02-01 17:50 蓬莱仙羽 阅读(225) 评论(0) 推荐(0)
摘要:用C#写一个类,实现输入一个字符串,返回一个MD5值的调用public static string GetMD5(string sDataIn) { MD5CryptoServiceProvider md5 = newMD5CryptoServiceProvider(); byte[] bytValue, bytHash; bytValue =System.Text.Encoding.UTF8.GetBytes(sDataIn); bytHash =md5.ComputeHash(bytValue); md5.Clear(); string sTemp = ""; for 阅读全文
posted @ 2013-02-01 15:41 蓬莱仙羽 阅读(177) 评论(0) 推荐(0)