博文

编译原理课程设计,词法自动机。(2006-05-24 19:19:00)

摘要://编译原理课程设计,词法自动机。 import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import java.io.*;import java.util.*;class frame extends JFrame implements ActionListener{ JButton button1=new JButton("打开现有文件"); JButton button2=new JButton("现场输入文件"); Choice ch=new Choice(); JButton button=new JButton("执行"); TextArea ta=new TextArea(); TextArea tb=new TextArea(); JFileChooser chooser=new JFileChooser(); FileInputStream readfile=null;  int b; byte buffer[]=new byte[25000]; String str=null; String id[]={"asm","cout","main","FALSE","TRUE","include","boolean","default","float","operator","abs","static_cast","union","auto","delete","for","private","struct","unsigned","bool","do","friend","protected","switch","using","break","double","goto","public","template","virtual","case","dynamic_cast","if","register","this","void","catch","else","inline","reinterpret_cast","throw","volatile","char","enum","int","......

阅读全文(6287) | 评论:2

中央空调模拟器(客户端全面版)(无图片)(2006-05-24 19:17:00)

摘要:import java.awt.*;import java.awt.event.*;import java.net.*;import javax.swing.*;import javax.swing.event.*;import java.io.*;import java.util.*; public class ktclient{ public static void main(String args[]) {  jiemian j=new jiemian();       }} class jiemian extends JFrame implements ActionListener{ String[] wsettem={ "初使状态","18.0 ℃","19.0 ℃","20.0 ℃","21.0 ℃","22.0 ℃","23.0 ℃","24.0 ℃","25.0 ℃","25.0 ℃","26.0 ℃","27.0 ℃","28.0 ℃","29.0 ℃","30.0 ℃","31.0 ℃","32.0 ℃"  };   JButton connect=new JButton("打开"); JButton disconnect=new JButton("关上"); JButton settem=new JButton("调节温度");  JPanel jp=new JPanel(); JPanel jpwdj=new JPanel();  JTextField jtconnect=new JTextField(); JComboBox jcbsettem1=new JComboBox(wsettem);  JLabel title=new JLabel("中央空调管理系统客户端程序"); JTextArea ltnr=new JTextArea();  JLabel jl1=new JLabel("当前温度"); JLabel jl2=new JLab......

阅读全文(19262) | 评论:0

中央空调模拟器(客户端简单版)(2006-05-24 19:15:00)

摘要://中央空调模拟器的客户端 import java.net.*;import javax.swing.*;import javax.swing.event.*;import java.awt.*;import java.awt.event.*;import java.io.*;public class c{ public static void main(String args[]) {  c_win w=new c_win();  w.setVisible(true); }}class c_win extends JFrame implements ActionListener{  Label label1=new Label("房间号:"); TextField tf1=new TextField(); Label label2=new Label("目标温度:"); TextField tf2=new TextField(); Label label3=new Label("当前温度:"); TextField tf3=new TextField(); Button button1=new Button("连接"); Button button2=new Button("取消"); Button button3=new Button("保持"); Button button4=new Button("改变"); String s1=null,s2=null; c_win() {  Container c=this.getContentPane();  c.setLayout(new GridLayout(5,3));    c.add(label1);    c.add(tf1);    c.add(label2);    c.add(tf2); ......

阅读全文(2628) | 评论:0

中央空调模拟器(服务器端)(2006-05-24 19:14:00)

摘要://中央空调模拟器的服务器端,最简模拟客户端为c.java import javax.swing.*;import javax.swing.event.*;import javax.swing.Timer;import java.awt.*;import java.awt.event.*;import java.io.*;import java.net.*;import java.util.*;class dialog extends JDialog implements ActionListener{ JLabel label; JPanel p1,p2; JButton button1,button2; JFrame f; boolean flag=false; dialog(JFrame f,String t,String s,boolean m) {  super(f,t,m);  this.f=f;  label=new JLabel(s);  p1=new JPanel();  p2=new JPanel();  button1=new JButton("确定");  button2=new JButton("取消");  p1.add(label);  p2.add(button1);  button1.addActionListener(this);  p2.add(button2);  button2.addActionListener(this);  this.getContentPane().add(p1,BorderLayout.CENTER);  this.getContentPane().add(p2,BorderLayout.SOUTH);  this.getContentPane().setVisible(true);  this.setModal(......

阅读全文(2808) | 评论:0

UTF8编码解码(2006-05-24 19:10:00)

摘要:{*******************************************************************************   UTF-8就是以8位为单元对UCS进行编码。从UCS-2到UTF-8的编码方式如下:   UCS-2编码(16进制) UTF-8 字节流(二进制)   0000 - 007F 0xxxxxxx  0080 - 07FF 110xxxxx 10xxxxxx  0800 - FFFF 1110xxxx 10xxxxxx 10xxxxxx   例如“汉”字的Unicode编码是6C49。6C49在0800-FFFF之间,所以肯定要用3字节模板了:1110xxxx 10xxxxxx 10xxxxxx。将6C49写成二进制是:0110 110001 001001, 用这个比特流依次代替模板中的x,得到:11100110 10110001 10001001,即E6 B1 89。 *******************************************************************************} unit uUnicodeUtils; interfaceuses SysUtils, windows; function Gb2Utf8(const GbStr:String):String;function Utf82Gb(const Utf8Str:String):String; implementation function Gb2Utf8(const GbStr:String):String;var  wideStr:array[0..2048] of WideChar;  SourceLength:integer;  DoneLength:integer;  AscNo:integer;  Byte1,Byte2,Byte3:integer;begin  Result := '';  //不做变化  //Result:=GbStr;  //exit;   SourceLength := Len......

阅读全文(4398) | 评论:0

写日志的接口(2006-05-24 18:58:00)

摘要:unit uProgLog; interface uses  Windows, SysUtils, SyncObjs; const  C_LOG_LEVEL_TRACE   = $00000001;  C_LOG_LEVEL_WARNING = $00000002;  C_LOG_LEVEL_ERROR   = $00000004;type  EnumSeverity = (TraceLevel, WarningLevel, ErrorLevel, LogLevel);   function SeverityDesc(severity: EnumSeverity): string; type  TLogFile = class  private    FLogKeepDays: Integer; //日志保存时间    FLogLevel: DWORD;      //日志级别    FLogPath: string;      //日志保存路径,以"\"结尾    FLogAppName: string;   //应用程序名(日志文件前缀)     FCsWriteLogFile: TCriticalSection;    FLogFile: TextFile;    //日志文件句柄    FLogOpened: Boolean;   //日志文件是否打开    FFileTimeStamp: TTimeStamp;  //当前日志文件创建或打开时间     function GetLogKeepDays(): Integer;    procedure Se......

阅读全文(2940) | 评论:0

读写注册表的接口程序(2006-05-24 18:56:00)

摘要:替换掉红色部分 unit uReadWriteReg; interface uses  registry, Windows; Const  SOFT_NAME = 'ScFltSearch';   function OpenRootKey(var Reg: TRegistry; canCreate: boolean): boolean;  procedure SetReg(Key: string; Value: string); overload;  procedure SetReg(Key: string; Value: integer); overload;  procedure SetReg(Key: string; Value: boolean); overload;  function GetReg(Key: string; var Value: string; default: string = ''): boolean; overload;  function GetReg(Key: string; var Value: integer; default: integer = 0): boolean; overload;  function GetReg(Key: string; var Value: boolean; default: boolean = false): boolean; overload;implementation function OpenRootKey(var Reg: TRegistry; canCreate: boolean): boolean;begin  result := true;  Reg := TRegistry.Create;  Reg.RootKey := HKey_CURRENT_USER;  if not Reg.KeyExists('SoftWare\' + SOFT_NAME) then  begin    Reg.OpenKey('SoftWare\' + SOFT_NAME, true);  &n......

阅读全文(2276) | 评论:0

预防打开多个窗口的小程序(2006-05-24 18:42:00)

摘要:以下红字部分是比一般程序多加入的部分,在编写时把相应部分加入工程文件的原代码并替换相应部分即可: program HotelSMS; uses  Windows,  Forms,  fmHotelSMS in 'fmHotelSMS.pas' {fmHotelSMSF},  dmData in 'dmData.pas' {dmDataM: TDataModule},  uReadWriteReg in 'uReadWriteReg.pas',  uProgLog in 'uProgLog.pas'; {$R *.res} const  strCaption = '酒店系统短信发送';var  MainHWnd,ChildHWnd: THandle;begin  //以查找窗口以保证只能同时启动一个实例  MainHWnd := FindWindow('TApplication', strCaption);  if IsWindow(MainHWnd) then  begin    ChildHWnd := GetLastActivePopUp(MainHWnd);    //激活已有的实例    SetForeGroundWindow(MainHWnd);    if (IsWindow(ChildHWnd)) and (ChildHWnd <> MainHWnd) and       IsWindowVisible(ChildHWnd) and IsWindowEnabled(ChildHWnd) then    begin      SetForeGroundWindow(ChildHWnd);    end;    Halt;  end;   Application.Initialize......

阅读全文(2598) | 评论:0

多位数乘法的汇编实现(二)(2005-08-19 17:31:00)

摘要:addition proc near start3:sub ax,ax       sub dx,dx       mov bx,offset op1       mov al,[bx+1]       mov si,ax       mov bx,offset op2       cmp byte ptr[bx],al                            jbe calc       mov di,ax       mov al,[bx+1]       mov si,ax       mov ax,0       push ax       popf ;------------------------------------------------------初始化运算 calc:  mov al,[bx+si+2]       mov dl,[bx+di+2]       adc al,dl ;--------------------......

阅读全文(3333) | 评论:0

多位数乘法的汇编实现(一)(2005-08-19 17:31:00)

摘要:.model small .stack 64 .data op1 db 11,?,11 dup(0) op2 db 11,?,11 dup(0) pro1 db 12 dup(0),'$' pro2 db 11 dup(0),'$' pro3 db 22 dup(0),'$' pro4 db 11 dup(0),'$' pro5 db 11 dup(0),'$' msg1 db 0dh,0ah,'**************************************************************'       db 0dh,0ah,'     This calculator only can bear 10 digits of operand!'       db 0dh,0ah,'               And the oprand shuld be no sign!'       db 0dh,0ah,'**************************************************************',0dh,0ah,'$' msg2 db 0dh,0ah,'Please input the FIRST operand(Press ENTER to finish):','$' msg3 db 0dh,0ah,'Please input the SECOND operand(Press ENTER to finish):','$' msg4 db 0dh,0ah,'The summation is: ','$' msg5 db 0dh,0ah,'The margin is:    ','$' msg6 db 0dh,0ah,'The product is:   ',......

阅读全文(4069) | 评论:0