|
2009年8月14日
#
冒泡排序法(java) 其实这个方法用得比较少.对于我来说是这样的.一般都是数据库排序.但在面试中这道题目的出现率去很高.一般还有个递归算法. public class lee0908143 { public static void main(String[] args) { int[] intNum={20,10,50,40,30,70,60,80,90,100}; //需要排序的数组 lee0908143 lee=new lee0908143(); intNum=lee.bubbleUp(intNum,true); System.out.println("从小到大排序为:"); for(int k=0;k<intNum.length;k++) System.out.println(intNum[k]); intNum=lee.bubbleUp(intNum,false); System.out.println("从小到大排序为:"); for(int k=0;k<intNum.length;k++) System.out.println(intNum[k]); } //冒泡排序方法intarray表示需要排序的数组 directmintomax=true表示排序从小到大 private int[] bubbleUp(int[] intarray,boolean directmintomax) { for(int i=0;i<intarray.length;i++) { for(int j=i+1;j<intarray.length;j++) { if(directmintomax) { //从小到大排序 if(intarray[i]>intarray[j]) { int intTemp=intarray[i]; intarray[i]=intarray[j]; intarray[j]=intTemp; } } else { //从大到小排序 if(intarray[i]<intarray[j]) { int intTemp=intarray[i]; intarray[i]=intarray[j]; intarray[j]=intTemp; } } } } return intarray; } }
2009年3月29日
#
本地计算机上的MSSQLSERVER服务启动后又停止了。一些服务自动停止,如果它们没有什么可做的,例如“性能日志和警
报“服务"
启动MSSQL SERVER 2000的时候报这个错误.当时莫名其妙.在网上搜索了一堆都是什么关闭VIA协议.打开一看.本来就是关的.
后来仔细回忆一下,发现昨天在 服务器网络实用工具 中把勾去掉.重启又可以了.原因不太明白.
2008年9月24日
#
面试时遇到的二道题,有点意思.贴出来做个纪念!
1.(C#的题目)1,1,2,3,5,8,13...,利用递归方法计算出第30位的结果?
 Code
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
/// <summary>
/// 递归调用,实现如1,1,2,3,5,8,13
/// </summary>
class Program
{
static void Main(string[] args)
{
Program p=new Program();
for (int i = 1; i < 31; i++)
{
Console.WriteLine("参数:{0},递归调用的结果是:{1}",i, p.ReturnValue(i));
}
}
/// <summary>
/// 递归调用的方法
/// </summary>
/// <param name="Num"></param>
/// <returns></returns>
int ReturnValue(int Num)
{
int re = new int();
if (Num == 1 || Num == 2)
re = 1;
else
re = ReturnValue(Num - 1) + ReturnValue(Num - 2);
return re;
}
}
}
2.(数据库题目)部门表unitBM如下
unitID parentID unitName
员工表personYG如下
autoID unitID nameYG
现知道部门ID(unitID)为'un001',找出该部门及该部门下N级子部门的所有员工信息.
其实这是一个无限分类的例子,当时想到的是用游标.后来回来想一下才改成这样!
 Code
if object_id('unitBM') is not null
drop table unitBM
go
create table unitBM
(
AutoID int identity(1,1) primary key,
unitID varchar(50),
parentID varchar(50),
unitName varchar(50)
)
insert into unitBM(unitID,parentID,unitName)
select 'un001','','总经办' union all
select 'un002','un001','财务部' union all
select 'un003','un001','电脑部' union all
select 'un006','un002','会计部' union all
select 'un009','','人事部'
go
if object_id('personYG') is not null
drop table personYG
go
create table personYG
(
AutoID int identity(1,1) primary key,
unitID varchar(50),
ygName varchar(50)
)
go
insert into personYG(unitID,ygName)
select 'un001','张三' union all
select 'un002','李四' union all
select 'un001','王五' union all
select 'un003','张六' union all
select 'un006','周八' union all
select 'un005','蔡九'
go
create function get_chileID(@unitID varchar(50))
returns @returntb table(unID varchar(50))
as
begin
insert into @returntb select @unitID
while @@rowcount>0
insert into @returntb
select a.unitID from unitBM a inner join @returntb b on a.parentID=b.unID
where a.unitID not in (select unID from @returntb)
return
end
select * from get_chileID('un001')
select * from personYG where unitID in(select * from get_chileID('un001'))
2008年7月9日
#
SQL子查询二则
1.查找唯一值
实现原理为:先取不与我相同的标识号的内容,而我的内容又不存在这些内容中,所以我的内容是唯一的.即即唯一值
例子:在一个用户表中取出唯一组的用户
if object_id('Test_Users') is not null
drop table Test_Users
go
create table Test_Users(AutoID int identity(1,1) primary key,UserGroupID int,UserName varchar(50))
go
set xact_abort on
begin tran
insert into Test_Users(UserGroupID,UserName)
select 2,'aa' union
select 2,'bb' union
select 3,'cc' union
select 1,'Admin' union
select 3,'ff' union
select 2,'pp'
commit tran
go
select * from Test_Users a
where UserGroupID not in
(select UserGroupID from Test_Users where AutoID<>a.AutoID)
---这样找出的结果是
AutoID UserGroupID UserName
----------- ----------- --------------------------------------------------
1 1 Admin
(所影响的行数为 1 行)
2.查找结果不重复
实现原理为:重复数据字段选择一个最大值或者最小值.而选择的时候指向这个值.其实这是把重复字段部分分成了组.但分组计算不能取所有数据.
--仍然用以上数据
--这是取最大值
select * from Test_Users a
where AutoID>=
(select max(AutoID) from Test_Users b where a.UserGroupID=b.UserGroupID)
--这是取最小值
select * from Test_Users a
where AutoID>=
(select max(AutoID) from Test_Users b where a.UserGroupID=b.UserGroupID)
--也可以用分组计算
select UserGroupID from Test_Users
group by UserGroupID
2008年6月18日
#
最近在用CoolCHM制作电子文档.发现这是一个共享版.在网上搜索到相关的破解方法.即C盘序列号与数字97648123相异或.再把得得到的二进制转换成为整型即得到注册码.
所以写了一个小程序学习一下.
界面如下

主要是一个button1和一个textBox1
代码如下:
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Text;
7 using System.Windows.Forms;
8 using Microsoft.VisualBasic;
9 using System.Management;
10 namespace CrackCoolCHM
11  {
12 public partial class Form1 : Form
13 {
14 public Form1()
15 {
16 InitializeComponent();
17 }
18
19 private void button1_Click(object sender, EventArgs e)
20 {
21 try
22 {
23 //获取C盘序列号
24 ManagementObject m_objDisk = new ManagementObject("win32_logicaldisk.deviceid='c:'");
25 string strSN = (string)m_objDisk.GetPropertyValue("VolumeSerialNumber");
26 //label2.Text = strSN;
27 //异或的代码
28 char[] YHCode = "97648123".ToCharArray();
29 string YHCodeResult = string.Empty;
30 foreach (char c in YHCode)
31 {
32 string s1 = Convert.ToString(Convert.ToInt32(c.ToString()), 2);
33 switch (s1.Trim().Length)
34 {
35 case 1:
36 s1 = "000" + s1;
37 break;
38 case 2:
39 s1 = "00" + s1;
40 break;
41 case 3:
42 s1 = "0" + s1;
43 break;
44 }
45 YHCodeResult += s1;
46 }
47 string Code16 = YHCodeResult;
48 //机器C盘的序列号
49 string MCCode = string.Empty;
50 char[] MachineCode = strSN.ToCharArray();
51 foreach (char c in MachineCode)
52 {
53 string s1 = Convert.ToString(Convert.ToInt32(c.ToString(), 16), 2);
54 switch (s1.Trim().Length)
55 {
56 case 1:
57 s1 = "000" + s1;
58 break;
59 case 2:
60 s1 = "00" + s1;
61 break;
62 case 3:
63 s1 = "0" + s1;
64 break;
65 }
66
67 MCCode += s1;
68 }
69 textBox1.Text = Convert.ToUInt32(ReturnXorValue(Code16, MCCode), 2).ToString();
70 }
71 catch(Exception ex)
72 {
73 MessageBox.Show("程序出错:" + ex.Message, "提示信息", MessageBoxButtons.OK);
74 }
75 }
76 string ReturnXorValue(string str1, string str2)
77 {
78 string ret = string.Empty;
79 string tempstr=string.Empty;
80 byte[] b1 = System.Text.Encoding.Default.GetBytes(str1);
81 byte[] b2 = System.Text.Encoding.Default.GetBytes(str2);
82 if (b1.Length != b2.Length) throw new ArgumentException("获取参数出错");
83 else
84 {
85 for (int i = 0; i < b1.Length; i++)
86 {
87 tempstr = (b1[i] ^ b2[i]).ToString();
88 ret += tempstr;
89 }
90 }
91 return ret;
92 }
93
94 private void exitToolStripMenuItem_Click(object sender, EventArgs e)
95 {
96 Application.Exit();
97 }
98 }
99 }
CoolCHM及注册机下载
注册机源文件
2008年3月20日
#
摘要: using System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using ... 阅读全文
2008年3月5日
#
摘要: [web开发] WMP-网页中常见属性和方法<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" id="wmp" width="0" height="0" style="width:0px;height:0px;"></object>//基本属... 阅读全文
2008年1月14日
#
2007年11月26日
#
2007年10月16日
#
|