源程序及注释.txt

合集下载

源程序说明书(井结构)

源程序说明书(井结构)

组件名称1.概述根据井号从数据库中提供描述信息生成井身结构图并显示。

2.功能描述1、支持井身结构图绘制根据显示区域大小自适应;2、支持绘制表层、技套一、技套二、技套三、油套、技套、尾管、表套、裸眼、套管外径、套管下深、下入深度、水泥返深、实际水泥返深、井身结构参数;3、支持本地保存功能(右键菜单);3.输入/输出说明3.1. 接口实现类说明:///<summary>///井结构绘制组件接口实现///</summary>public class DrawWellProvider : ClassDefine.IComponent{#region字段private DataComponent.DataSourceManagerImpl vDataSourceManagerImpl;///<summary>///井结构绘制窗体实例///</summary>private WellStructDisplay _ui;private DataTable _dataSource;private Control _container;#endregion#region属性///</summary>//数据源IDpublic string SJYID{get;set;}public DataSourceManagerImpl DATASOURCEMANAGER{get; set;}#endregion#region IComponent 成员///<summary>///组件初始化///</summary>///<param name="Parameter">组件初始化参数</param>///<returns>成功与否</returns>public string Initialize(string init){vDataSourceManagerImpl = newDataComponent.DataSourceManagerImpl();vDataSourceManagerImpl = DATASOURCEMANAGER;//vDataSourceManagerImpl.SetPropertyValue("SjyID", SJYID);////vDataSourceManagerImpl.Invoke(INVOKSTRING);//vDataSourceManagerImpl.Invoke("SetQueryDataParameter",//"<ParamInfo><FilterStr>SJYID=5050,5051;P_JH1=百泉1</FilterStr></ParamInfo>");vDataSourceManagerImpl.QueryDataEvent +=newClassDefine.QueryDataDelegate(vDataSourceManagerImpl_QueryDataEvent);(BindingSource)vDataSourceManagerImpl.GetDataSource(SJYID);DataTable _dataSource = (DataTable)vbs.DataSource;if (_dataSource == null)return"数据源加载出错";else{DataTable vdata = _dataSource; //(DataSet) vbs.DataSource;ValiData _vali = new ValiData();_vali.getdata(vdata);//用来判断DataSet中数据是否是丼结构需要的业务数据。

源程序12 16

源程序12  16

STARTK BIT P1.0 ;启动键STOPK BIT P1.1 ;停止键ORG 0000HLJMP MAINLJMP SPAIKORG 0003HORG 0013HLJMP STUOKORG 0030HMAIN:SETB P0.0 ;低水位选择端SETB P0.1 ;中水位选择端SETB P0.2 ;高水位选择端SETB P0.3 ;电机正转SETB P0.4 ;电机反转SETB P2.0 ;进水阀SETB P2.1 ;浸泡显示SETB P2.2 ;正转显示SETB P2.3 ;反转显示SETB P2.4 ;排水阀SETB P2.5 ;脱水电机显示SETB P2.6 ;蜂鸣报警端MOV R4,#3H ;洗衣脱水3次CLR IT0 ;电平触发方式CLR IT1;开中断SETB EA ;开总中断SETB EX0 ;开外部中断0SETB EX1 ;开外部中断1NK1:JNB STARTK,A0 ;查询启动键是否按下AJMP NK1NK2:JNB STOPK,T2 ;停止键JB STOPK,$;所有端口全部清零,即停止洗衣子程序T2:MOV P0,#0FFHMOV P1,#0FFHMOV P2,#0FFHMOV P3,#0FFHRETA0:MOV R3,#3H ;洗衣3次MOV A,P0ANL A,#07HCLR P2.0 ;开进水阀CJNE A,#6,D1 ;选择水位MOV R7,#10 ;选择低水位,延时5秒DEL5S:JNB STOPK,T2 ;判断是否按下停止按钮LCALL DELAYDJNZ R7,DEL5SLJMP ZZD1:CJNE A,#5,D2MOV R7,#20DEL10S:JNB STOPK,T2 ;判断是否按下停止按钮LCALL DELAY ;选择中水位,延时10秒DJNZ R7,DEL10SLJMP ZZD2:MOV R7,#30 ;选择高水位,延时15秒DEL15S:JNB STOPK,T2 ;判断是否按下停止按钮LCALL DELAYDJNZ R7,DEL15SZZ:SETB P2.0 ;关进水阀CLR P2.1 ;浸泡显示端LCALL DEL2S ;延时2秒SETB P2.1A1:MOV R7,#6 ;正转6秒DEL6S:JNB STOPK,T2 ;判断是否按下停止按钮CLR P2.2 ;正转显示端CLR P0.3 ;电动机正转LCALL DELAYSETB P2.2LCALL DELAYDJNZ R7,DEL6SSETB P0.3LCALL DEL2S ;停止2秒MOV R7,#6DEL61S:JNB STOPK,T2 ;判断是否按下停止按钮CLR P2.3 ;反转6秒CLR P0.4LCALL DELAYSETB P2.3LCALL DELAYDJNZ R7,DEL61SSETB P0.4LCALL DEL2S ;停止2秒DJNZ R3,A1 ;判断是否洗衣3次,若是则往下执行,否则跳转到A1CLR P2.4 ;开排水阀MOV R7,#30 ;排水15秒DE1L15S: ;判断是否按下停止按钮LCALL DELAYDJNZ R7,DE1L15SMOV R7,#40 ;脱水20秒,闪烁DEL20S:JNB STOPK,TIAO2 ;判断是否按下停止按钮CLR P2.5 ;开脱水电机CLR P0.3LCALL DELAYSETB P2.5LCALL DELAYDJNZ R7,DEL20SSETB P2.4 ;关排水阀SETB P0.3DJNZ R4,TIAO1 ;判断是否洗衣总过程3次,若是则往下执行,否则跳转到TIAO1LCALL T2 ;调停止洗衣子程序;开报警蜂鸣端MOV R7,#12 ;延时12秒DEL12S: CLR P2.6LCALL DELAYSETB P2.6LCALL DELAYDJNZ R7,DEL12SSETB P2.6 ;关报警蜂鸣端RETTIAO1:LCALL A0 ;调洗衣总过程程序RETTIAO2:LCALL T2 ;调停止洗衣总程序RETSPAIK:CLR P2.4 ;手动排水定时中断SETB P0.3SETB P0.4MOV R5,#30Z1:JNB STOPK,TIAO2 ;判断是否按下停止按钮LCALL DELAYDJNZ R5,Z1SETB P2.4RETISTUOK:CLR P2.4 ;手动脱水定时中断CLR P2.5SETB P0.3SETB P0.4MOV R5,#40Z2:JNB STOPK,TIAO2 ;判断是否按下停止按钮LCALL DELAYDJNZ R5,Z2SETB P2.4SETB P2.5RETI;//0.5的延时子程序DELAY:MOV R0,#50DEL: MOV R1,# 40DEL1: MOV R2,#123NOPDEL2: DJNZ R2,DEL2DJNZ R1,DEL1DJNZ R0,DELRET;//2秒的延时子程序DEL2S: MOV R6,#4DE:JNB STOPK,TIAO2 ;判断是否按下停止按钮ACALL DELAYDJNZ R6,DERETEND。

源程序

源程序

#include "src\STC12C5A.h"#include <intrins.h> //51基本运算(包括_nop_空函数)#include <math.h>#include "src\Define.h"///////全局变量///////uchar data DelayTime=9;uchar data gain=6,tt=0;uchar idata refreshflag[40];uchar data LEDBuf[35]; //15列;从左到右;亮的位为真(1);#include "src\ADC.c"#include "src\fft.h"uchar code ax[]={0,0,0,0,0,0,0,0, //“爱心”图标数组0,0,0,0,0,0,0,0,0x00,0x00,0x00,0x70,0xF8,0xFC,0xFE,0x7F,0x7F,0x7F,0xFE,0xFC,0xF8,0x70,0x00,0x00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};void Delays(uint t) //延时函数{uint j;while(--t){for(j=0;j<5;j++);}}void IOINIT() //初始化IO口工作模式{P0M1 = 0x00; P0M0 = 0xff; P0=0; //点阵列(Y)(L:OFF;H,H+:ON,ON+;)P1M1 = B(01000011); P1M0 = B(00110000);P1=B(10111111); //(P17@(高阻,IN)&P16@(高阻,IN) ... P11@(高阻,IN)AD2;P10@(高阻,IN)AD1;P2M1 = B(00000000); P2M0 = B(11111111);P2=0; //点阵行(X0(Left))(L:OFF;H,H+:ON,ON+;)P3M1 = B(00000000); P3M0 = B(11111111);P3=0; //点阵行(X1(Right))(L:OFF;H,H+:ON,ON+;)P1ASF =B(00000011); //将P10,P11的IO设置为模拟输入功能;}void BufToLED_Refresh() //把LEDBuf的数值数据传到P0,通过LED显示出来{uchar data i; //定义循环变量iuint temp=0x7fff; //定义tempfor(i=0;i<32;i+=2) //循环16次操作{P0=0x00; //P0输出低电平P2=temp/256; //P2为前8位P3=temp%256; //P3为后8位P0=~LEDBuf[i]; //调用LEDBuf数组取反Delays(DelayTime); //延时一下P2=0xff; //消隐P3=0xff; //消隐temp>>=1; //右移一位temp|=0x8000; //目的是为从左到右依次允许点亮LED(列)提供条件}}void LOVE() //“爱心”图标显示{uchar data i; //定义循环变量iuint temp=0x7fff; //定义tempfor(i=0;i<16;i++) //循环16次操作{P0=0x00; //P0输出低电平P2=temp/256; //P2为前8位P3=temp%256; //P3为后8位P0=ax[i+tt]; //调用“爱心”图标数据Delays(DelayTime); //延时一下P2=0xff; //消隐P3=0xff; //消隐temp>>=1; //右移一位temp|=0x8000; //目的是为从左到右依次允许点亮LED(列)提供条件}}void Timer_INT() //定时器初始化{TMOD = 0x10; //高4位控制T/C1EA = 1; //开总中断TH1 = 0x00; //16位计数寄存器T1高8位TL1 = 0x00; //16位计数寄存器T1低8位ET1 = 1; //T/C1中断开TR1 = 1; //T/C1启动}void ax_xs() //爱心显示{uint pp=4000; //定义pp=4000while(pp--) //如果PP减1后为真(即pp减1后不为0,直到pp=0才跳出while循环){if(pp%250==0) //如果PP/250,余数为0(即pp能被250整除){tt++; //tt加1}LOVE(); //“爱心”图标显示}pp=4000; //pp重新赋值0while(pp--) //如果PP减1后为真(即pp减1后不为0,直到pp=0才跳出while循环){LOVE(); //“爱心”图标显示}pp=4000; //pp重新赋值0while(pp--) //如果PP减1后为真(即pp减1后不为0,直到pp=0才跳出while循环){if(pp%250==0) //如果PP/250,余数为0(即pp能被250整除){tt++; //tt加1}LOVE(); //“爱心”图标显示}}void Main() //主函数入口{uint data Count=700; //定义变量Countuchar data i,Cgain,num=0; //定义变量i,Cgain,numIOINIT(); //初始化IO口工作模式ax_xs(); //爱心显示InitADC(); //ADC初始化Timer_INT(); //定时器初始化while(1) //主循环{for(i=0;i<65;i++) //for循环操作65次(读取64次ADC转换结果){dd[i].real=(GetADCResult(0)+GetADCResult(1))<<gain;//读取ad 结果并放大2 的gain(变量)次方,然后给FFT 算法的缓存区赋值}processfft(); //傅立叶变化及处理if(dd[2].real<32) //如果读取到的AD结果<32(即音频幅度太小){if(++Count==300) //电平值过小,则降低gain,减少噪音的电平显示{Count=0; //Count清0gain=6; //gain=6}}else //否则在AD结果在正常音频范围{Count=1; //Count赋值1(为下次的音频幅度太小做准备)if(++num==0xAF) //播放时,Auto gain;{num=0; //num清0/*自动增益的作用: 当输入的音频信号的音量变大或变小时,采样的AD 值幅度也会有相应趋势的变化,于是根据这个值自动调节AD 值放大的倍数,维持在一定的范围内,从而使显示的效果最好,不会出现满屏或者空屏的现象*///自动增益;Automatic gain;Cgain=dd[2].real/32;if(7<Cgain<=8){gain=4; //4}else if(4<Cgain<=6){gain=5; //5}else if(2<Cgain<=4){gain=6; //6}else{gain=7; //7}}}}}void LEDRefresh_INT() interrupt 3 //定时器中断服务函数{TH1 = 0x8A; //定时15msTL1 = 0xD0; //定时时间越小显示越清楚,但是频谱变化越缓慢//反之......大....抖动大.....频谱变化越快BufToLED_Refresh(); //把LEDBuf的数值数据传到P0,通过LED显示出来//刷新显示缓存区数据来点亮点阵屏}。

ex2_10-数值微分法例题源程序及注释

ex2_10-数值微分法例题源程序及注释
DXX=SXX-SX*SX/N DYY=SYY-SY*SY/N DXY=SXY-SX*SY/N B=DXY/DXX A=(SY-B*SX)/N R=DXY/SQRT(DXX*DYY) RETURN END
SUBROUTINE LGRG2(X,Y,N,T,Z) DIMENSION X(N),Y(N) DOUBLE PRECISION X,Y,T,Z,S Z=0.0 IF(N.LE.0)RETURN IF(N.EQ.1)THEN Z=Y(1) RETURN END IF IF(N.EQ.2)THEN Z=(Y(1)*(T-X(2))-Y(2)*(T-X(1)))/(X(1)-X(2)) RETURN END IF IF(T.LE.X(2))THEN K=1 M=3
!非线性问题转化为线性问题
!调用线性回归子程序 !反应级数 !速率常数
! 程序结束
SUBROUTINE CF(N,H,X,Y,Z) DIMENSION X(N),Y(N),Z(N) DOUBLE PRECISION X,Y,Z,H,T,YA,YB T=X(1)+H CALL LGRG2(X,Y,N,T,YA) T=X(1)+2*H CALL LGRG2(X,Y,N,T,YB) Z(1)=(4*YA-3*Y(1)-YB)/(2*H)
!线性回归子程序
!子程序结束 !拉格朗日插值子程序
ELSE IF(T.GE.X(N-1))THEN K=N-2 M=N
ELSE
K=1
M=N
10 IF(IABS(K-M).NE.1)THEN
L=(K+M)/2
IF(T.LT.X(L))THEN
M=L
ELSE
K=L
ENDIF
GOTO 10

源程序

源程序

Form1( 菜单.frm)Option ExplicitPrivate Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As LongPrivate Declare Function GetTickCount Lib "kernel32" () As LongConst DT_BOTTOM As Long = &H8Const DT_CALCRECT As Long = &H400Const DT_CENTER As Long = &H1Const DT_EXPANDTABS As Long = &H40Const DT_EXTERNALLEADING As Long = &H200Const DT_LEFT As Long = &H0Const DT_NOCLIP As Long = &H100Const DT_NOPREFIX As Long = &H800Const DT_RIGHT As Long = &H2Const DT_SINGLELINE As Long = &H20Const DT_TABSTOP As Long = &H80Const DT_TOP As Long = &H0Const DT_VCENTER As Long = &H4Const DT_WORDBREAK As Long = &H10Private Type RECTLeft As LongTop As LongRight As LongBottom As LongEnd TypeConst ScrollText As String = "设计题目:送瓶机" & vbCrLf & _vbCrLf & "工作原理及工艺动作过程:" & _ vbCrLf & "为了清洗圆形瓶子外面" & _vbCrLf & "需将瓶子推到上" & _vbCrLf & "同向转动的导辊" & vbCrLf & _ vbCrLf & "送瓶机的主要动作:" & _vbCrLf & "将到位的瓶子沿着导轨推动" & _ vbCrLf & " 然后通过另一个曲柄滑块" & _ vbCrLf & "将瓶子的送到转动的导辊上" & _ vbCrLf & "导辊带动瓶子旋转" & _vbCrLf & "推动瓶子沿导辊前进" & _vbCrLf & "转动的刷子就将瓶子洗净" & _ vbCrLf & "这里我只设计了" & _vbCrLf & "前半部分的送瓶机构" & _vbCrLf & "后面的洗瓶机构" & _vbCrLf & "还有出瓶机构" & _vbCrLf & "都没有设计出来" & _vbCrLf & "洗瓶机构已经有人设计出来了" & _vbCrLf & "出瓶机构有点困难" & _vbCrLf & "具体的说明我会写在课程设计说明书中" & _vbCrLf & "大家可以进行参考设计"Dim EndingFlag As BooleanConst pi = 3.1415926Public t, l1, l2, l3, l4, x0, y0, x1, y1, x2, y2, a0, b0, a1, b1, a2, b2, w As DoublePrivate Sub label5_Click()Timer1.Enabled = TrueLabel1.Visible = TruePicture2.Scale (0, 0)-(11000, 11000)End SubPrivate Sub label6_Click()Timer1.Enabled = FalsePicture2.Scale (0, 0)-(11000, 11000)End SubPrivate Sub Form_Load()Top = 0Left = 0Form1.Height = Screen.HeightForm1.Width = Screen.WidthTimer1.Enabled = FalsepicScroll.ForeColor = vbWhitepicScroll.FontSize = 14picScroll.DrawWidth = 4picScroll.Font = "华文行楷"Label1.Visible = FalseEnd SubPrivate Sub label7_Click()MsgBox "谢谢欣赏我的程序"EndEnd SubPrivate Sub mnui参考资料_Click()Form14.ShowEnd SubPrivate Sub mnui设计要求_Click()Form15.ShowEnd SubPrivate Sub mnusent不完全齿轮机构_Click()Form10.ShowEnd SubPrivate Sub mnusent连杆机构_Click()Form6.ShowEnd SubPrivate Sub mnusent偏心轮机构_Click()Form7.ShowEnd SubPrivate Sub mnusent凸轮机构_Click()Form8.ShowEnd SubPrivate Sub Timer1_Timer()t = t + pi * w / 180ClsdrawEnd SubPrivate Sub draw()w = 1l1 = 1200l2 = 4800x0 = 1500y0 = 2500x1 = x0 + l1 * Cos(t)y1 = y0 - l1 * Sin(t)x2 = x0 + l1 * (Cos(t) + l2 / l1 - 0.25 * l1 / l2 + 0.25 * l1 / l2 * Cos(2 * t))y2 = 3500l3 = 1200l4 = 4800a0 = 8000b0 = 7500a1 = a0 + l3 * Cos(t - pi / 2)b1 = b0 - l3 * Sin(t - pi / 2)a2 = 8000b2 = b0 - l3 * (Cos(t - pi) + l4 / l3 - 0.25 * l3 / l4 + 0.25 * l3 / l4 * Cos(2 * (t - pi)))Picture2.ClsPicture2.DrawWidth = 3Picture2.Line (x0, y0)-(x1, y1), vbBluePicture2.Line -(x2, y2), vbBluePicture2.Line (x2 - 200, y2 - 100)-(x2 + 200, y2 - 100), vbBlue Picture2.Line -(x2 + 200, y2 + 100), vbBluePicture2.Line -(x2 - 200, y2 + 100), vbBluePicture2.Line -(x2 - 200, y2 - 100), vbBluePicture2.Line (x0 - 200, y0 + 200)-(x0, y0), vbGreenPicture2.Line -(x0 + 200, y0 + 200), vbGreenPicture2.Line -(x0 - 200, y0 + 200), vbGreenPicture2.DrawWidth = 3Picture2.Line (5000, 3700)-(7600, 3700), vbRedPicture2.DrawWidth = 3Picture2.Line (a0, b0)-(a1, b1), vbBluePicture2.Line -(a2, b2), vbBluePicture2.Line (a2 - 200, b2 - 100)-(a2 + 200, b2 - 100), vbBlue Picture2.Line -(a2 + 200, b2 + 100), vbBluePicture2.Line -(a2 - 200, b2 + 100), vbBluePicture2.Line -(a2 - 200, b2 - 100), vbBluePicture2.Line (a0 - 200, b0 + 200)-(a0, b0), vbGreenPicture2.Line -(a0 + 200, b0 + 200), vbGreenPicture2.Line -(a0 - 200, b0 + 200), vbGreenPicture2.DrawWidth = 1Picture2.Line (7700, 3300)-(7700, 1500), vbYellowPicture2.Line (7200, 3300)-(7200, 1500), vbYellowPicture2.Line (7750, 3300)-(7750, 1500), vbYellowPicture2.Line (8250, 3300)-(8250, 1500), vbYellowPicture2.DrawWidth = 2Picture2.Circle (x0, y0), l1, vbYellowPicture2.Circle (a0, b0), l3, vbYellowPicture2.Circle (x0, y0), 50, vbYellowPicture2.Circle (x1, y1), 50, vbYellowPicture2.Circle (x2, y2), 50, vbYellowPicture2.Circle (a0, b0), 50, vbYellowPicture2.Circle (a1, b1), 50, vbYellowPicture2.Circle (a2, b2), 50, vbYellowEnd SubPrivate Sub mnuhelp画线_Click()Form3.ShowEnd SubPrivate Sub mnuhelp画圆_Click()Form4.ShowEnd SubPrivate Sub mnuhelp曲柄滑块_Click()Form11.ShowEnd SubPrivate Sub mnuhelp双曲柄机构_Click()Form9.ShowEnd SubPrivate Sub mnumove加速度分析_Click()Form5.ShowEnd SubPrivate Sub mnumove速度分析_Click()Form2.ShowEnd SubPrivate Sub mnumove位置分析_Click()Form13.ShowEnd SubPrivate Sub Form_Activate()RunMainEnd SubPrivate Sub RunMain()Dim LastFrameTime As LongConst IntervalTime As Long = 40Dim rt As LongDim DrawingRect As RECTDim UpperX As Long, UpperY As Long 'Upper left point of drawing rect Dim RectHeight As LongForm1.RefreshGet the size of the drawing rectangle by suppying the DT_CALCRECT constant rt = DrawText(picScroll.hdc, ScrollText, -1, DrawingRect, DT_CALCRECT) If rt = 0 Then 'errMsgBox "Error scrolling text", vbExclamationEndingFlag = TrueElseDrawingRect.Top = picScroll.ScaleHeightDrawingRect.Left = 0DrawingRect.Right = picScroll.ScaleWidthRectHeight = DrawingRect.BottomDrawingRect.Bottom = DrawingRect.Bottom + picScroll.ScaleHeight End IfDo While Not EndingFlagIf GetTickCount() - LastFrameTime > IntervalTime ThenpicScroll.ClsDrawText picScroll.hdc, ScrollText, -1, DrawingRect, DT_CENTER Or DT_WORDBREAKDrawingRect.Top = DrawingRect.Top - 1DrawingRect.Bottom = DrawingRect.Bottom - 1If DrawingRect.Top < -(RectHeight) Then 'time to resetDrawingRect.Top = picScroll.ScaleHeightDrawingRect.Bottom = RectHeight + picScroll.ScaleHeight End IfpicScroll.RefreshLastFrameTime = GetTickCount()End IfDoEventsLoopUnload MeSet Form1 = NothingEnd SubPrivate Sub Form_Unload(Cancel As Integer)EndingFlag = TrueEnd SubPrivate Sub Timer2_Timer()If Label1.Left > -25000 And Label1.Left < 13000 ThenLabel1.Left = Label1.Left - 100ElseLabel1.Left = 12000Label1.Left = Label1.Left - 100End IfEnd SubFor13.(位置分析)Option ExplicitPrivate Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As LongPrivate Declare Function GetTickCount Lib "kernel32" () As LongConst DT_BOTTOM As Long = &H8Const DT_CALCRECT As Long = &H400Const DT_CENTER As Long = &H1Const DT_EXPANDTABS As Long = &H40Const DT_EXTERNALLEADING As Long = &H200Const DT_LEFT As Long = &H0Const DT_NOCLIP As Long = &H100Const DT_NOPREFIX As Long = &H800Const DT_RIGHT As Long = &H2Const DT_SINGLELINE As Long = &H20Const DT_TABSTOP As Long = &H80Const DT_TOP As Long = &H0Const DT_VCENTER As Long = &H4Const DT_WORDBREAK As Long = &H10Private Type RECTLeft As LongTop As LongRight As LongBottom As LongEnd TypeConst ScrollText As String = "如图所示,矢量方程式为" & vbCrLf & _vbCrLf & "L1+L2=Yc" & _vbCrLf & "L1eiψ1+L2eiψ2=yc " & _vbCrLf & "展开后分别取虚部和实部得" & _vbCrLf & "L1sinψ1+L2sin(180-ψ2)=0" & _vbCrLf & "所以" & _vbCrLf & " 180-ψ2=arcsin(-L1sinψ1)/ψ2" & _vbCrLf & "ψ2=180-arcsin(-L1sinψ1/ψ2)" & _vbCrLf & "yc=L1codψ1-L2cosψ2" & _vbCrLf & "这里我定义一个的坐标范围" & _vbCrLf & "输入的长度最好不要超过10000" Dim EndingFlag As BooleanConst pi = 3.1415926Public t, l1, l2, Xc, w As DoublePrivate Sub label5_Click()Timer1.Enabled = TruePicture2.Scale (-10, 10000)-(100, -500)Picture2.DrawWidth = 3Picture2.Line (-10, 0)-(100, 0), vbBluePicture2.Line (0, 10000)-(0, -500), vbBlueEnd SubPrivate Sub label6_Click()Timer1.Enabled = FalsePicture2.Scale (-10, 10000)-(100, -500)Picture2.DrawWidth = 3Picture2.Line (-10, 0)-(100, 0), vbBluePicture2.Line (0, 10000)-(0, -500), vbBlueEnd SubPrivate Sub label7_Click()Unload MeEnd SubPrivate Sub label4_Click()Text1.Text = 1200Text2.Text = 4800Text3.Text = 1End SubPrivate Sub Form_Load()Top = 0Left = 0Form13.Height = Screen.HeightForm13.Width = Screen.WidthTimer1.Enabled = FalsepicScroll.ForeColor = vbWhitepicScroll.FontSize = 14picScroll.DrawWidth = 4picScroll.Font = "华文行楷"End SubPrivate Sub Timer1_Timer()t = t + pi * w / 180drawEnd SubPrivate Sub draw()l1 = Text1.Textl2 = Text2.Textw = Text3.TextXc = l1 * (Cos(t) + l2 / l1 - 0.25 * l1 / l2 + 0.25 * l1 * Cos(2 * t) / l2)Text4.Text = XcPicture2.DrawWidth = 2Picture2.PSet (t, Xc), vbYellowEnd SubPrivate Sub Form_Activate()RunMainEnd SubPrivate Sub RunMain()Dim LastFrameTime As LongConst IntervalTime As Long = 40Dim rt As LongDim DrawingRect As RECTDim UpperX As Long, UpperY As Long 'Upper left point of drawing rectDim RectHeight As LongForm13.Refreshrt = DrawText(picScroll.hdc, ScrollText, -1, DrawingRect, DT_CALCRECT)If rt = 0 Then 'errMsgBox "Error scrolling text", vbExclamationEndingFlag = TrueElseDrawingRect.Top = picScroll.ScaleHeightDrawingRect.Left = 0DrawingRect.Right = picScroll.ScaleWidthRectHeight = DrawingRect.BottomDrawingRect.Bottom = DrawingRect.Bottom + picScroll.ScaleHeightEnd IfDo While Not EndingFlagIf GetTickCount() - LastFrameTime > IntervalTime ThenpicScroll.ClsDrawText picScroll.hdc, ScrollText, -1, DrawingRect, DT_CENTER Or DT_WORDBREAKDrawingRect.Top = DrawingRect.Top - 1DrawingRect.Bottom = DrawingRect.Bottom - 1If DrawingRect.Top < -(RectHeight) Then 'time to resetDrawingRect.Top = picScroll.ScaleHeightDrawingRect.Bottom = RectHeight + picScroll.ScaleHeightEnd IfpicScroll.RefreshLastFrameTime = GetTickCount() End IfDoEventsLoopUnload MeSet Form13 = NothingEnd SubPrivate Sub Form_Unload(Cancel As Integer) EndingFlag = TrueEnd Sub。

粗大误差检验源程序(已注释)

粗大误差检验源程序(已注释)
glbstable95[9]=2.11;glbstable99[9]=2.32;
glbstable95[10]=2.18;glbstable99[10]=2.41;
glbstable95[11]=2.23;glbstable99[11]=2.48;
glbstable95[12]=2.29;glbstable99[12]=2.55;
frame=new JFrame("窗口1");//定义一个新的窗口并决定其窗口名
frame.setLayout(null);//窗口使用绝对布局
con = frame.getContentPane();//将窗体转化成容器
con.setLayout(null);//容器使用绝对布局
xwntable[10]=1.96;
xwntable[11]=2.00;
xwntable[12]=2.04;
xwntable[13]=2.07;
xwntable[14]=2.10;
xwntable[15]=2.13;
xwntable[16]=2.16;
xwntable[17]=2.18;
JP1_JB1.setBounds(200, 100, 100, 50);//设置第一个界面5个按钮的位置(布局)
JP1_JB2.setBounds(100, 170, 300, 30);
JP1_JB3.setBounds(100, 200, 300, 30);
JP1_JB4.setBounds(100, 230, 300, 30);
private double glbstable95[] = new double[101];
private double glbstable99[] = new double[101];

源程序

源程序

//主程序入口代码using System;using System.Windows.Forms;namespace MREDIDG{///<summary>/// Class with program entry point.///</summary>internal sealed class Program{///<summary>/// Program entry point.///</summary>[STAThread]private static void Main(string[] args){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new MainForm());}}}//主界面相应代码using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;using Newtonsoft.Json;using Newtonsoft.Json.Linq;using System.Data;using System.IO;using System.Web;using ponentModel;using System.Linq;using System.Text;using System.Runtime.InteropServices;using Winista.Text.HtmlParser;using Winista.Text.HtmlParser.Lex;using Winista.Text.HtmlParser.Util;using Winista.Text.HtmlParser.Tags;using Winista.Text.HtmlParser.Filters;using Word = Microsoft.Office.Interop.Word;using System.Threading;namespace MREDIDG{/// <summary>/// Description of MainForm./// </summary>public partial class MainForm :BaseDockTab{static int ImagesControls=0;static string ImagePath="";string NowOperatePath;string AnjianMingCheng;//案件名称string JianChaDuiXiang;//检查对象string KaiShiShiJian;//时间string ComFressFileMd5Value;//压缩文档md5值long ComFressFileSize;//压缩文档空间占用大小string ComFressFileName;//压缩包名称string JianCaichiyouxinxi;//检材持有信息int Number = 0;Root rt;mon.ConfigOperate config = new mon.ConfigOperate(mon.ConfigFileType.AppConfig);private ClassLib.ImportExportToWord IEW;public Microsoft.Office.Interop.Word.Document wordDocument { get; set; }public MainForm(){//// The InitializeComponent() call is required for Windows Forms designer support.//InitializeComponent();//// TODO: Add constructor code after the InitializeComponent() call.//Icon ic0 = myExtractIcon("%SystemRoot%\\system32\\shell32.dll", 15);TreeImageList.Images.Add(ic0);Icon ic1 = myExtractIcon("%SystemRoot%\\system32\\shell32.dll", 5);TreeImageList.Images.Add(ic1);Icon ic2 = myExtractIcon("%SystemRoot%\\system32\\shell32.dll", 7);TreeImageList.Images.Add(ic2);Icon ic3 = myExtractIcon("%SystemRoot%\\system32\\shell32.dll", 11);TreeImageList.Images.Add(ic3);Icon ic4 = myExtractIcon("%SystemRoot%\\system32\\shell32.dll", 3);TreeImageList.Images.Add(ic4);Icon ic5 = myExtractIcon("%SystemRoot%\\system32\\shell32.dll", 4);TreeImageList.Images.Add(ic5);Icon ic6 = myExtractIcon("%SystemRoot%\\system32\\shell32.dll", 101);TreeImageList.Images.Add(ic6);}/// <summary>/// 分析文档内容/// </summary>void AnalysisFile(){ComFressFileMd5Value = config.GetValue("FILEMD5");richTextBox_Tag.Text += "\r\n报告压缩文档的MD5值为:" +ComFressFileMd5Value;ComFressFileSize = long.Parse(config.GetValue("ZIPSIZE"));richTextBox_Tag.Text += "\r\n报告压缩文档的大小为:" + (ComFressFileSize/1024)+"kb";GetDrive();HTMLParser(NowOperatePath + "\\Report\\Catalog.html");string a = txtHtmlWhole.Text;// System.IO.File.ReadAllText(NowOperatePath+ "\\Report\\Catalog.html");a = a.Replace(" ", "");int h = a.IndexOf("zNodes");a = a.Remove(0, h);h = a.IndexOf("$(document).ready(function()");a = a.Remove(h, a.Length - h);a = a.Replace("zNodes=", "").Trim();a = a.Remove(a.Length - 1, 1);a = a.Replace("\r\n", "").Replace("\t", "");a = a.Replace("{id:", "{\"id\":\"").Replace(",pId:", "\",\"pId\":\"").Replace(",name:", "\",\"name\":").Replace(",url:", ",\"url\":").Replace(",target:", ",\"target\":").Replace(",icon:", ",\"icon\":").Replace("'", "\"");a = a.Replace(":*,", ":\"*\",");a = a.Replace("},]", "}]").Replace("㊣", "").Replace(" ", "").Replace(" ", "").Replace(" ", "").Replace(" ", "").Replace("-", "").Replace(" ", "").Replace("\"\"", "\"");//this.richTextBox1.Text=a;rt = JsonConvert.DeserializeObject<Root>("{\"ZjlbItem\":" + a + "}");this.richTextBox_Tag.Text += "\r\n处理证据列表信息....\r\n";System.IO.File.WriteAllText(ClassLib.GlobalClass.WorkPath + "\\local\\证据列表JSON.txt", "{\"ZjlbItem\":" + a + "}");a = null;//string b=rt.zjlbitem[2].name.ToString();string pid = rt.ZjlbItem[2].id.ToString();int j = 1;string t = ""; string url = "";for (int i = 0; i < rt.ZjlbItem.Count; i++){if (rt.ZjlbItem[i].pId.ToString() == pid){t += "\r\n证据" + j + ":" + rt.ZjlbItem[i].name.ToString() + ",url=" + rt.ZjlbItem[i].url.ToString();j++;}if (rt.ZjlbItem[i].name.IndexOf("基本信息") >= 0){t += "基本信息url=" + rt.ZjlbItem[i].url.ToString();url += rt.ZjlbItem[i].url.ToString() + ";";}}rt = null;HTMLParser(NowOperatePath + "\\Report\\Contents0.html");string anjianxinxi = txtHtmlWhole.Text; //System.IO.File.ReadAllText(NowOperatePath+ "\\Report\\Contents0.html");h = anjianxinxi.IndexOf("案件名称");anjianxinxi = anjianxinxi.Remove(0, h);h = anjianxinxi.IndexOf("</td></tr>");//案件名称AnjianMingCheng = anjianxinxi.Remove(h, anjianxinxi.Length - h).Replace("</td><td>", ":");h = anjianxinxi.IndexOf("案件时间");anjianxinxi = anjianxinxi.Remove(0, h);//笔录时间//string startTime, endTime;h = anjianxinxi.IndexOf("</td></tr>");KaiShiShiJian = anjianxinxi.Remove(h, anjianxinxi.Length - h).Replace("</td><td>", ":");//检查对象信息JianChaDuiXiang= "";// string JianCaichiyouren;//检材持有人// string JianCai;//检材信息this.richTextBox_Tag.Text += "\r\n"+AnjianMingCheng + "\r\n" + KaiShiShiJian + "\r\n";for (int x = 0; x < url.Split(';').Length; x++){string jbxxs = ""; string tagname = "";if (url.Split(';')[x].ToString() != ""){HTMLParser(NowOperatePath + "\\Report\\" + url.Split(';')[x].Split('#')[0].ToString());jbxxs = txtHtmlWhole.Text; //System.IO.File.ReadAllText(NowOperatePath+ "\\Report\\" + url.Split(';')[x].Split('#')[0].ToString());tagname = url.Split(';')[x].ToString().Split('#')[1].ToString();h = jbxxs.IndexOf("<tr><th><a name=\"" + tagname + "\">");jbxxs = jbxxs.Remove(0, h);h = jbxxs.IndexOf("<div style=");jbxxs = jbxxs.Remove(h, jbxxs.Length - h);jbxxs = jbxxs.Replace("</td><td>", ":").Replace("</td></tr>", ";");string strText = System.Text.RegularExpressions.Regex.Replace(jbxxs, "<[^>]+>", "");strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");this.richTextBox_Tag.Text += "\r\n处理检查对象" + (x + 1) + "....\r\n";System.IO.File.WriteAllText(ClassLib.GlobalClass.WorkPath + "\\local\\检查对象" + x + ".txt", strText);string jbxxjson = "";strText = strText.Trim();h = strText.IndexOf(";");strText = strText.Remove(0, h);strText = strText.Remove(0, 1);strText = strText.Remove(strText.Length - 1, 1);strText = strText.Replace(";;", ";");string strid, strname, strcontent;jbxxjson = "{\"JbxxItem\":[";for (int y = 0; y < strText.Split(';').Length; y++){string str1 = strText.Split(';')[y].ToString();strid = "\"id\":\"" + str1.Split(':')[0] + "\"";strname = "\"name\":\"" + str1.Split(':')[1] + "\"";if (str1.IndexOf("时间:") >= 0){int s = str1.IndexOf("时间:");strcontent = "\"content\":\"" + str1.Remove(0, s + 3) + "\"";}else{strcontent = "\"content\":\"" + str1.Split(':')[2] + "\"";}jbxxjson += "{" + strid + "," + strname + "," + strcontent + "},";}jbxxjson += "]}";jbxxjson = jbxxjson.Replace("},]}", "}]}");System.IO.File.WriteAllText(ClassLib.GlobalClass.WorkPath + "\\local\\检查对象" + x + "JSON.txt", jbxxjson);this.richTextBox_Tag.Text += "\r\n生成检查对象JSON" + (x + 1) + "....\r\n"+ jbxxjson;rt = JsonConvert.DeserializeObject<Root>(jbxxjson);JianChaDuiXiang += rt.JbxxItem[13].content + "牌手机一部(型号:" + rt.JbxxItem[14].content + ",系统及版本:" + rt.JbxxItem[11].content + rt.JbxxItem[12].content + ")," + rt.JbxxItem[16].name + ":" + rt.JbxxItem[16].content + "," + rt.JbxxItem[17].name + ":" + rt.JbxxItem[17].content + ",";if (rt.JbxxItem[18].content != "")JianChaDuiXiang += rt.JbxxItem[18].name + ":" + rt.JbxxItem[18].content + ",";JianChaDuiXiang += "手机SIM卡号:" + rt.JbxxItem[1].content + ",";if (rt.JbxxItem[2].content != "")JianChaDuiXiang += "手机SIM卡号2:" + rt.JbxxItem[2].content + ",";JianChaDuiXiang += "手机持有人:" + rt.JbxxItem[0].content;JianCaichiyouxinxi+=rt.JbxxItem[0].content+"提供的"+rt.JbxxItem[13].content+"牌"+rt.JbxxItem[14].content+"手机";rt = null;}if (x <url.Split(';').Length - 2){JianChaDuiXiang += ";";JianCaichiyouxinxi+="和";}else if(x ==url.Split(';').Length - 2)JianChaDuiXiang += "。

源程序(带注释)

源程序(带注释)

源程序(带注释)#include "stdio.h"#include "stdlib.h"#include "string.h"#define MAX 3 /*车库容量*/#define price 0.05 /*每车每分钟费用*/ typedef struct time{int hour;int min;}Time; /*时间结点*/typedef struct node{char num[10];Time reach;Time leave;}CarNode; /*车辆信息结点*/typedef struct NODE{CarNode *stack[MAX+1];int top;}SeqStackCar; /*模拟车站*/typedef struct car{CarNode *data;struct car *next;}QueueNode;typedef struct Node{QueueNode *head;QueueNode *rear;}LinkQueueCar; /*模拟通道*/void InitStack(SeqStackCar *); /*初始化栈*/int InitQueue(LinkQueueCar *); /*初始化便道*/int Arrival(SeqStackCar *,LinkQueueCar *); /*车辆到达*/ void Leave(SeqStackCar *,SeqStackCar *,LinkQueueCar *); /*车辆离开*/void List(SeqStackCar,LinkQueueCar); /*显示存车信息*/ void main(){SeqStackCar Enter,Temp;LinkQueueCar Wait;int ch;InitStack(&Enter); /*初始化车站*/InitStack(&Temp); /*初始化让路的临时栈*/InitQueue(&Wait); /*初始化通道*/while(1){printf("***************************************");printf("\n1.the car arrive");printf("\t2.the car leave");printf("\n\n\n3.the schedule");printf("\t\t4.out\n");printf("***************************************\n"); while(1){scanf("%d",&ch);if(ch>=1&&ch<=4) break;else printf("\n please choose:1|2|3|4.");}switch (ch){case 1:Arrival(&Enter,&Wait);break; /*车辆到达*/case 2:Leave(&Enter,&Temp,&Wait);break; /*车辆离开*/ case 3:List(Enter,Wait);break; /*列表打印信息*/case 4:exit(0); /*退出主程序*/default:break;}}}void InitStack(SeqStackCar *s) /*初始化栈*/{int i;s->top=0;for(i=0;i<=MAX;i++)s->stack[s->top]=NULL;}int InitQueue(LinkQueueCar *Q) /*初始化便道*/{Q->head->next=NULL;Q->rear=Q->head;return(1);}void PRINT(CarNode *p) /*打印出栈车的信息*/{int room;int A1,A2,B1,B2;printf("\n please input the depart time: ");scanf("%d:%d",&(p->leave.hour),&(p->leave.min));printf("\n the number of the car:");puts(p->num);printf("\n the time the car arrive:%d:%d",p->reach.hour,p->reach.min);printf("thedeparttime:%d:%d",p->leave.hour,p->leave.min);A1=p->reach.hour;A2=p->reach.min;B1=p->leave.hour;B2=p->leave.min;printf("\nthefee:%2.1fyuan",((B1-A1)*60+(B2-A2))*price) ;free(p);}int Arrival(SeqStackCar *Enter,LinkQueueCar *W) /*车辆到达*/{CarNode *p;QueueNode *t;p=(CarNode *)malloc(sizeof(CarNode));flushall();printf("\n input the number of the car:");gets(p->num);if(Enter->top<MAX) /*车场未满,车进车场*/{Enter->top++;/* printf("\n the place of the car:",Enter->top); */ printf("\n the time the car arrive:");scanf("%d:%d",&(p->reach.hour),&(p->reach.min));Enter->stack[Enter->top]=p;return(1);}else /*车场已满,车进便道*/{printf("\n gai che xu zai bian dao dengdai!\n");t=(QueueNode *)malloc(sizeof(QueueNode));t->data=p;t->next=NULL;W->rear->next=t;W->rear=t;return(1);}}void Leave(SeqStackCar *Enter,SeqStackCar *Temp,LinkQueueCar *W){ /*车辆离开*/int i,room;CarNode *p,*t;QueueNode *q;/*判断车场内是否有车*/if(Enter->top>0) /*有车*/{while(1) /*输入离开车辆的信息*/{printf("\n qing shuru che zai chechang de weizhi/1--%d/:",Enter->top);scanf("%d",&room);if(room>=1&&room<=Enter->top)break;}while(Enter->top>room) /*车辆离开*/{Temp->top++;Temp->stack[Temp->top]=Enter->stack[Enter->top];Enter->stack[Enter->top]=NULL;Enter->top--;}p=Enter->stack[Enter->top];Enter->stack[Enter->top]=NULL;Enter->top--;while(Temp->top>=1){Enter->top++;Enter->stack[Enter->top]=Temp->stack[Temp->top];Temp->stack[Temp->top]=NULL;Temp->top--;}PRINT(p);/*判断通道上是否有车及车站是否已满*/if((W->head!=W->rear)&&Enter->top<MAX) /*便道的车辆进入车场*/{q=W->head->next;t=q->data;Enter->top++;printf("\n biandao de %s haoche jinru chechang di %d weizhi",t->num,Enter->top);/* printf("\n qing shuru xianzai de shijian:"); */scanf("%d:%d",&(t->reach.hour),&(t->reach.min));W->head->next=q->next;if(q==W->rear)W->rear=W->head;Enter->stack[Enter->top]=t;free(q);}else printf("]n biandaoli meiyou che. \n");}else printf("chechangli meiyou che."); /*没车*/}void List1(SeqStackCar *S) /*列表显示车场信息*/{ int i;if(S->top>0) /*判断车站内是否有车*/{printf("\n chechang:");printf("\n weizhi daodashijian chepaihao\n");for(i=1;i<=S->top;i++){printf("%d",i);printf("%d:%d",S->stack[i]->reach.hour,S->stack[i]->rea ch.min);puts(S->stack[i]->num);}}else printf("\n chechangli meiyou che");}void List2(LinkQueueCar *W) /*列表显示便道信息*/{QueueNode *p;p=W->head->next;if(W->head!=W->rear) /*判断通道上是否有车*/{printf("\n dengdai chelian de haoma wei:");while(p!=NULL){puts(p->data->num);p=p->next;}}else printf("\n biandaoli meiyou che.");}void List(SeqStackCar S,LinkQueueCar W){int flag,tag;flag=1;while(flag){printf("\n qingxuanze 1|2|3:");printf("\n 1.chechang\n 2.biandao\n 3.fanhui\n"); while(1){scanf("%d",&tag);if(tag>=1||tag<=3)break;else printf("\n qingxuanze 1|2|3:");}switch(tag){case 1:List1(&S);break; /*列表显示车场信息*/case 2:List2(&W);break; /*列表显示便道信息*/case 3:flag=0;break;default:break;}}}。

源程序

源程序

三、源程序:#include <iostream>#include <string.h>#include <conio.h>#include <windows.h>#define MaxSpace 100#define keylen 6#define RADIX_n 10#define RADIX_c 26#define SHOW_MSG_ERROR "\n错误信息:航班号须由2位大写字母和4位数字组成。

\n输入数据错误,程序终止执行!\n"using namespace std;typedef char KeyType;typedef struct {char start[6]; //起点char end[6]; //终点char sche[6]; //班期char time1[4]; //起飞时间char time2[4]; //到达时间char model[3]; //机型int price; //票价}InfoType; //航班记录类型typedef struct {KeyType keys[keylen]; //关键字(航班号)InfoType others;int next;}SLNode; //静态链表结点类型typedef struct {SLNode sl[MaxSpace]; //静态链表int keynum; //关键字字符数int length; //表长}SLList; //静态链表类型typedef int ArrType_n[RADIX_n];typedef int ArrType_c[RADIX_c];KeyType key[keylen],kl[4];/*====================函数声明*/void Distribute(SLNode *sl, int i, ArrType_n &f, ArrType_n &e);void Collect(SLNode *sl, int i, ArrType_n f, ArrType_n e);void Distribute_c(SLNode *sl, int i, ArrType_c &f, ArrType_c &e);void Collect_c(SLNode *sl, int i, ArrType_c f, ArrType_c e);void RadixSort(SLList &L);void Arrange(SLList &L);int BinSearch(SLList L, KeyType key[]);void SeqSearch(SLList L, KeyType key[],int i);void DisplayStyle(int i, char *s);void Display(SLList L, int i);void Quit(void);void searchcon(SLList L);void Prompt(void);bool InputData(SLList &L);bool Check_HangBanHao(char *HangBanHao);/*----------------------------- 数字字符分配函数*/void Distribute(SLNode *sl, int i, ArrType_n &f, ArrType_n &e){int j,p;for(j=0;j<RADIX_n;j++)f[j]=0;for(p=sl[0].next; p; p=sl[p].next){j=sl[p].keys[i]%48; //将数字字符映射为十进制数字if(!f[j]) //--------------------------------//f[j]=p; //|else //| 将p指向的结点插入到第j个子表中sl[e[j]].next=p; //|e[j]=p; //--------------------------------//}}/*----------------------------- 数字字符收集函数*/void Collect(SLNode *sl, ArrType_n f, ArrType_n e){int j,t;for(j=0;!f[j];j++); //找第一个非空子表sl[0].next=f[j]; //将sl[0].next指向第一个非空子表的第一个结点t=e[j];while(j<RADIX_n-1){for(j=j+1;j<RADIX_n-1 && !f[j];j++); //找下一个非空子表if(f[j]){sl[t].next=f[j];t=e[j]; //链接到主链表}}sl[t].next=0;}/*----------------------------- 字母字符分配函数*/void Distribute_c(SLNode *sl, int i, ArrType_c &f, ArrType_c &e){int j,p;for(j=0;j<RADIX_c;j++)f[j]=0;for(p=sl[0].next; p!=0; p=sl[p].next){j=sl[p].keys[i]%65; //将字母字符映射为字母集中的相应序号if(!f[j]) //--------------------------------//f[j]=p; //|else //| 将p指向的结点插入到第j个子表中sl[e[j]].next=p; //|e[j]=p; //--------------------------------//}}/*----------------------------- 字母字符收集函数*/void Collect_c(SLNode *sl, ArrType_c f, ArrType_c e){int j,t;for(j=0;!f[j]; j++); //找第一个非空子表sl[0].next=f[j];t=e[j]; //将sl[0].next指向第一个非空子表的第一个结点while(j<RADIX_c-1){for(j=j+1;j<RADIX_c-1 && !f[j];j++); //找下一个非空子表if(f[j]){sl[t].next=f[j];t=e[j]; //链接到主链表}}sl[t].next=0;}/*----------------------------- 链式基数排序函数*/void RadixSort(SLList &L){int i;ArrType_n fn,en;ArrType_c fc,ec;for(i=0; i<L.length;i++) //将线性表改造为静态链表L.sl[i].next=i+1;L.sl[L.length].next=0; //"0"表示空指针//-------------------------- 按最低位优先依次对各关键字进行分配和收集for(i=L.keynum-1;i>=2;i--) //对低四位数字部分进行分配和收集{Distribute(L.sl,i,fn,en);Collect(L.sl,fn,en);}for(i=1;i>=0;i--) //对高位的2位字母进行分配和收集{Distribute_c(L.sl,i,fc,ec);Collect_c(L.sl,fc,ec);}}/*RAdixSort*//*----------------------------- 按指针链整理线性表*/void Arrange(SLList &L){int p,q,i;SLNode temp;p=L.sl[0].next; //p指向第一个结点for(i=1;i<L.length;i++){while(p<i) //查找第i个结点,并用p指向此结点p=L.sl[p].next;q=L.sl[p].next;if(p!=i) //若第i个结点不在当前位置,交换结点数据{temp=L.sl[p];L.sl[p]=L.sl[i];L.sl[i]=temp;L.sl[i].next=p;}p=q; //p指向下一个未调整结点}}/*Arrange*//*------------------- 二分查找函数*/int BinSearch(SLList L, KeyType key[]){ int low,high,mid;low=1; high=L.length;while(low<=high){mid=(low+high)/2;if(strcmp(key,L.sl[mid].keys)==0)return mid;else if(strcmp(key,L.sl[mid].keys)<0)high=mid-1;else low=mid+1;}return 0;}/*BinSearch*//*------------------- 顺序查找函数*/void SeqSearch(SLList L, KeyType key[],int i){ int j,k,m=0;for(j=1;j<=L.length;j++){switch(i){case 2:k=strcmp(key,L.sl[j].others.start);break;case 3:k=strcmp(key,L.sl[j].others.end); break;case 4:k=strcmp(key,L.sl[j].others.time1);break;case 5:k=strcmp(key,L.sl[j].others.time2);break;}if(k==0){m=1;Display(L,j);}}if(m==0)printf("很抱歉,无此航班信息。

源程序

源程序

#include<stdio.h>#include<stdlib.h>#include<conio.h>#include<string.h>struct book{long booknum;char name[20];char press[20];char category[20];char author[20];int year;int month;int day;double price;char state[20];struct book *next;};struct book *Creatbook();struct book *InsertBook(struct book *head,struct book *newbook); struct book *Deletebook(struct book *head,long booknum); struct book *Modifibook(struct book *head);struct book *borrowbook(struct book *head);void sortbook(struct book *head);void Printbook(struct book *head);void surveybook(struct book *head);void fprint_book(struct book *head);void price_paixu(struct book *head);void time_paixu(struct book *head);int main(void){struct book *head,*b,*p;long booknum;char name[20];char press[20];char category[20];char author[20];int year;int month;int day;double price;char state[20];int choice,mychoice;int size;char mima[6];char mi[10]="123456";int i,j;head=NULL;printf("---------------------------------------------------\n");printf("******************欢迎使用本系统*******************\n");printf("---------------------------------------------------\n");printf("【【【【【【【【1-学生 2-管理员】】】】】】】】\n");printf("---------------------------------------------------\n");printf("【【【【【【【【-----0-退出程序----】】】】】】】】\n");printf("请选择:");scanf("%d",&mychoice);while(mychoice!=0){if(mychoice==1){head=borrowbook(head);fprint_book(head);}if(mychoice==2){i=1;while(i<4){printf("请输入密码:");for(j=0;j<6;j++){mima[j]=getch();printf("*");}mima[j]='\0';printf("\n");if(strcmp(mima,mi)!=0){printf("密码错误,请重新输入!\n");system("pause");system("cls");i++;}else{printf("密码正确!\n");system("pause");system("cls");size=sizeof(struct book);printf("------------------------------------------------------------\n");printf("|*********************图书馆管理系统目录********************|\n");printf("------------------------------------------------------------\n");printf("|【【【【【【【【|1-录入新书2-删除书籍|】】】】】】】】|\n");printf("------------------------------------------------------------\n");printf("|【【【【【【【【|3-查询书籍4-浏览书籍|】】】】】】】】|\n");printf("------------------------------------------------------------\n");printf("|【【【【【【【【|5-修改图书 6-插入书籍|】】】】】】】】|\n");printf("------------------------------------------------------------\n");printf("|【【【【【【【【|7-书籍排序 0-退出程序|】】】】】】】】|\n");printf("------------------------------------------------------------\n");printf("请输入你的选择:");scanf("%d",&choice);while(choice!=0){switch(choice){case 1:head=Creatbook();fprint_book(head);break;case 2:printf("请输入图书编号:");scanf("%ld",&booknum);head=Deletebook(head,booknum);Printbook(head);printf("删除成功!");fprint_book(head);system("pause");break;case 3:surveybook(head);system("pause");break;case 4:Printbook(head);system("pause");break;case 5:head=Modifibook(head);fprint_book(head);system("pause");break;case 6:printf("请输入图书编号、书名、作者、出版社、类别、出版时间、价格、状态:");scanf("%ld%s%s%s%s%d%d%d%lf%s",&booknum,name,author,press,cate gory,&year,&month,&day,&price,state);p=head;while(p!=NULL){if(p->booknum==booknum){mychoice=1;break;}p=p->next;}if(mychoice==1){b=(struct book *)malloc(size);b->booknum=booknum;strcpy(b->name,name);strcpy(b->author,author);strcpy(b->press,press);strcpy(b->category,category);b->year=year;b->month=month;b->day=day;b->price=price;strcpy(b->state,state);head=InsertBook(head,b);fprint_book(head);system("pause");}elseprintf("编号已存在,请重新输入选择!\n");break;case 7:sortbook(head);default:printf("输入错误。

源程序

源程序

printf("y= %4.1f%+4.1fi\n",y.re,y.im);
//跳过最大数和最小数
printf("%6d",a[i]); printf("\n"); //最后输出一个换行符
} 【例 3-2】输入一串字符(以'\n'结束),统计其中大写字母 A,B,C,…,Z 各出现多 少次。只输出那些至少出现一次的字母(每 4 个字母占一行),并输出 26 个大写字母中共出 现过多少个(或都没出现过)的信息。
scanf("%f%f%f%f",&x.re,&x.im,&y.re,&y.im);
a.re=x.re+y.re; a.im=x.im+y.im; //求 a=x+y
b.re=x.re-y.re; b.im=x.im-y.im; //求 b=x-y
c.re=x.re*y.re-x.im*y.im; //求 c=x×y
printf("\n");
}
}
【例 3-8】 将数组 a[N]的元素排列成由小到大形式(冒泡排序)。
#include <stdio.h>
#define N 8
void main( )
{ int a[N],i,j,x;
printf("请输入数组 s 的%d 个元素:\n",N);
for(i=0;i<N;++i)scanf("%d",&a[i]);
if(a[i][j]<a[mini][minj])mini=i,minj=j; //找最小元素所在的行列号

源程序说明书(井结构)

源程序说明书(井结构)

组件名称1.概述根据井号从数据库中提供描述信息生成井身结构图并显示。

2.功能描述1、支持井身结构图绘制根据显示区域大小自适应;2、支持绘制表层、技套一、技套二、技套三、油套、技套、尾管、表套、裸眼、套管外径、套管下深、下入深度、水泥返深、实际水泥返深、井身结构参数;3、支持本地保存功能(右键菜单);3.输入/输出说明3.1. 接口实现类说明:///<summary>///井结构绘制组件接口实现///</summary>public class DrawWellProvider : ClassDefine.IComponent{#region字段private DataComponent.DataSourceManagerImpl vDataSourceManagerImpl;///<summary>///井结构绘制窗体实例///</summary>private WellStructDisplay _ui;private DataTable _dataSource;private Control _container;#endregion#region属性///</summary>//数据源IDpublic string SJYID{get;set;}public DataSourceManagerImpl DATASOURCEMANAGER{get; set;}#endregion#region IComponent 成员///<summary>///组件初始化///</summary>///<param name="Parameter">组件初始化参数</param>///<returns>成功与否</returns>public string Initialize(string init){vDataSourceManagerImpl = newDataComponent.DataSourceManagerImpl();vDataSourceManagerImpl = DATASOURCEMANAGER;//vDataSourceManagerImpl.SetPropertyValue("SjyID", SJYID);////vDataSourceManagerImpl.Invoke(INVOKSTRING);//vDataSourceManagerImpl.Invoke("SetQueryDataParameter",//"<ParamInfo><FilterStr>SJYID=5050,5051;P_JH1=百泉1</FilterStr></ParamInfo>");vDataSourceManagerImpl.QueryDataEvent +=newClassDefine.QueryDataDelegate(vDataSourceManagerImpl_QueryDataEvent);(BindingSource)vDataSourceManagerImpl.GetDataSource(SJYID);DataTable _dataSource = (DataTable)vbs.DataSource;if (_dataSource == null)return"数据源加载出错";else{DataTable vdata = _dataSource; //(DataSet) vbs.DataSource;ValiData _vali = new ValiData();_vali.getdata(vdata);//用来判断DataSet中数据是否是丼结构需要的业务数据。

源程序

源程序

{ int i,j,maxj;
for(i=0;i<M;i++)
{ maxj=0;
for(j=1;j<N;j++)
if(a[i][j]>a[i][maxj])maxj=j;
b[i]=a[i][maxj];
}
} 【例 4-17】 将 a 和 b 两个变量调整成 a≤b 形式的函数。 采用的方法是:若 a≤b,则直接返回;否则交换它们的值。
{
int t; for(;i<j;i++,j--)t=x[i],x[i]=x[j],x[j]=t;
return;
} 【例 4-16】二维数组作形参的函数设计示例(求 a[M][N]每行最大元素值)。
#define M 4
#define N 5
void maxline(int a[M][N],int b[M] )
//主函数
{
//上述函数声明也可以放在此处
int a, b, c ;
scanf("%d%d", &a,&b);
c=add(a,b);
printf("sum is %d\n", c);
}
int add(int x, int y) //函数定义
{ int m;
m=x+y;
return m;
}
【例 4-5】 计算两个正整数最大公约数的函数。
if(n%i==0)return 0; //若发现 n 的真因子 i,返回 n 不是素数的信息
else i+=2;
return 1;
//n 没有真因子,返回 n 是素数的信息
}

程序及注释

程序及注释

;RMDZ.ASMCON8279 EQU 0492H ;定义CON8279为地址0492HDAT8279 EQU 0490H ;定义DAT8279为地址0490HCS0809 EQU 04D0H ;定义CS0809为地址04D0HASSUME CS:CODE;将CS段寄存器设置为存放CODE逻辑段的段地址CODE SEGMENT PUBLIC ;定义CODE逻辑段,组合类型为PUBLIC ORG 100H ;规定程序的起始地址为100HSTART:MOV DX,CS0809 ;将CS0809的地址04D0H装入DX寄存器MOV AL,34H ;将34H装入AL寄存器OUT DX,AL ;向地址04D0H输出值34H以进行初始化WAIT:MOV CX,0010H ;将循环次数0010H装入CX寄存器WAIT1:NOPNOP ;空操作LOOP WAIT1 ;循环执行WAIT1次数为0010H次MOV DX,CS0809 ;将CS0809的地址04D0H装入DX寄存器IN AL,DX ;从地址04D0H读出数据存至AL寄存器MOV BL,AL ;将AL寄存器的数据装入BL寄存器MOV DI, OFFSET V ALUETAB ;取变量V ALUETAB的偏移地址装入DI寄存器MOV BH, 00H ;使BH寄存器的值清零COMP1:MOV AL, CS:[DI] ;取变量V ALUETAB的第一个操作数存入AL寄存器CMP AL, BL ;比较AL和BL寄存器中值的大小JBE PRO1 ;若AL寄存器的值(V ALUETAB的值)不高于BL寄存器的;值(热敏电阻模块输出值),则跳转到PRO1JMP PRO2 ;否则跳转至PRO2PRO1:INC BH ;BH寄存器的值加一INC DI ;DI寄存器的值加一以指向V ALUETAB的下一个操作数JMP COMP1 ;跳转回COMP1PRO2:MOV AL, CS:[DI] ;将V ALUETAB中满足上述条件的此操作数存入AL寄存器MOV CL, AL ;将AL寄存器的数据装入CL寄存器DEC BH ;BH寄存器的值减一,此时BH寄存器的值就是所测温度十位数;上的数字DEC DI ;DI寄存器的值减一以指向V ALUETAB的前一个操作数MOV AL, CS:[DI] ;将此操作数存入AL寄存器SUB CL, AL ;CL寄存器的值减去AL寄存器的值MOV AL, CS:[DI] ;同上,将V ALUETAB的操作数存入AL寄存器SUB BL, AL ;BL寄存器的值减去AL寄存器的值MOV AL, 0AH ;将0AH装入AL寄存器MUL BL ;BL寄存器的值乘以0AH并存入AX寄存器DIV CL ;AX寄存器的值除以CL寄存器的值,商存入AL寄存器MOV BL, AL ;把商装入BL寄存器,经上述换算后,此时BL寄存器的值;就是所测温度个位数上的数字;========数码管显示模块========DISP:MOV DI,OFFSET SEGCOD ;取变量SEGCOD的偏移地址存入DI寄存器MOV AX,08H ;将08H装入AX寄存器MOV DX, CON8279 ;将地址0492H装入DX寄存器OUT DX, AX ;向地址0492H输出值08H进行数码管显示模块的初始化MOV AX, 90H ;将90H装入AX寄存器MOV DX, CON8279 ;将地址0492H装入DX寄存器OUT DX, AX ;向地址0492H输出值90H进行数码管显示模块的初始化MOV DX, DAT8279 ;将地址0490H装入DX寄存器MOV AL, BH ;将BH寄存器的值(温度十位数)装入AL寄存器MOV AH, 00H ;AH寄存器的值清零ADD DI, AX ;令DI寄存器的值加上AX寄存器的值,此时DI指向;SEGCOD中显示此温度十位数的数字的操作数MOV AL,CS:[DI] ;将DI指向的SEGCOD中的操作数存入AL寄存器OUT DX,AL ;向地址0490H输出AL寄存器的值使数码管显示相应的数字NOPNOP ;空操作MOV DI,OFFSET SEGCOD ;取变量SEGCOD的偏移地址存入DI寄存器MOV AL, BL ;将BL寄存器的值(温度个位数)装入AL寄存器MOV AH, 00H ;AH寄存器的值清零ADD DI, AX ;令DI寄存器的值加上AX寄存器的值,此时DI指向;SEGCOD中显示此温度个位数的数字的操作数MOV AL,CS:[DI] ;将DI指向的SEGCOD中的操作数存入AL寄存器OUT DX, AL ;向地址0490H输出AL寄存器的值使第二位数码管显示相应;的数字;=======数码管显示模块结束=======;=======LCD显示模块=======WRTAB: ;写TABLE变量MOV SI, OFFSET ASCIITAB;取变量ASCIITAB的偏移地址存入SI寄存器MOV DI, OFFSET TABLE ;取变量TABLE的偏移地址存入DI寄存器ADD DI, 1BH;DI寄存器的值加1BH,令DI指向TABLE中的第一个“?”MOV AL, BH ;将BH寄存器的值(温度十位数)装入AL寄存器MOV AH, 00H ;AH寄存器的值清零ADD SI, AX ;SI寄存器的值加AX寄存器的值,此时SI指向ASCIITAB;中表示此温度十位数的数字的ASCII码MOV AL, [SI] ;将SI指向的ASCIITAB中的ASCII码存入AL寄存器MOV [DI], AL ;将此ASCII码存入TABLE变量中的第一个“?”处MOV SI, OFFSET ASCIITAB ;取变量ASCIITAB的偏移地址存入SI寄存器ADD DI, 04H ;DI寄存器的值加04H,令DI指向TABLE中的第二个“?”MOV AL, BL ;将BL寄存器的值(温度个位数)装入AL寄存器MOV AH, 00H ;AH寄存器的值清零ADD SI, AX ;SI寄存器的值加AX寄存器的值,此时SI指向ASCIITAB;中表示此温度个位数的数字的ASCII码MOV AL, [SI] ;将SI指向的ASCIITAB中的ASCII码存入AL寄存器MOV [DI], AL ;将此ASCII码存入TABLE变量中的第二个“?”处DISPLCD: ;LCD显示MOV DX, 04A6H ;将地址04A6H装入DX寄存器MOV AX, 88H ;将88H装入AX寄存器OUT DX, AX ;向地址04A6H输出值88H进行LCD显示模块的初始化MOV AX, 70H ;将70H装入AX寄存器OUT DX, AX ;向地址04A6H输出值70H进行LCD显示模块的初始化MOV AL, 0F4H ;将0F4H装入AL寄存器CALL COMD ;调用COMD程序段CALL DELAY ;调用DELAY程序段START1:MOV SI,OFFSET TABLE ;取变量TABLE的偏移地址存入SI寄存器MOV CX, 36 ;由于TABLE中共有36个操作数,因此WR1需执行36次,;将循环次数36装入CX寄存器WR1:MOV DX, 04A4H ;将地址04A4H装入DX寄存器IN AX, DX ;读地址04A4H的值,存入AX寄存器AND AX, 80H ;将AX寄存器的值与80H进行与操作,目的是判断BUSY;是否为0JNZ WR1 ;若BUSY不为0,返回执行WR1,否则继续执行下面程序MOV AL, CS:[SI] ;将SI指向的TABLE中的操作数存入AL寄存器CALL COMD ;调用COMD程序段INC SI ;SI寄存器的值加一以指向TABLE中的下一个操作数LOOP WR1 ;循环执行WR1直至CX=0CALL DELAY ;调用DELAY程序段OK: JMP ALARM ;跳转至语音报警模块ALARM程序段DELAY: MOV CX,1000H ;DELAY程序段,将循环次数1000H存入CX寄存器DLYB: LOOP DLYB ;循环执行DL YB,次数为1000HRET ;过程返回指令COMD: ;COMD程序段MOV DX, 04A0H ;将地址04A0H装入DX寄存器OUT DX, AL ;向地址04A0H输出AL寄存器的值MOV DX, 04A6H ;将地址04A6H装入DX寄存器MOV AX, 71H ;将71H装入AX寄存器OUT DX, AX ;向地址04A6H输出AX寄存器的值,使REQ置位MON:MOV DX, 04A4H ;将地址04A4H装入DX寄存器IN AX, DX ;读地址04A4H的值,存入AX寄存器AND AX, 80H ;将AX寄存器的值与80H进行与操作,目的是判断BUSY;是否为1JZ MON ;若BUSY不为1,返回执行MON,否则继续执行下面程序MOV DX, 04A6H ;将地址04A6H装入DX寄存器MOV AX, 70H ;将70H装入AX寄存器OUT DX ,AX ;向地址04A6H输出AX寄存器的值,使REQ复位RET ;过程返回指令TABLE DB0F0H,00H,00H,21,17,0F0H,01H,00H,39,16,0F0H,02H,00H,46,34,0F0H,03H,00H,22 ,40,0F1H,08H,05H,58,0F1H,09H,05H,?,0F1H,0AH,05H,?;TABLE变量,存放使LCD进行显示的命令,;表示“当前温度:**(温度十位数字)(温度个位数字)”ASCIITAB DB30H,31H,32H,33H,34H,35H,36H,37H,38H,39H,41H,42H,43H,44H,45H,46H;ASCIITAB变量,按顺序存放从0到F的ASCII码;=======LCD显示模块结束=======;=======语音报警模块=======ALARM:MOV DX, 04B0H ;将地址04B0H装入DX寄存器MOV AL, 0AH ;将0AH装入AL寄存器MUL BH ;BH寄存器的值(温度十位数)乘以0AH并存入AX寄存器,;实际上只使用到AL寄存器,AH寄存器的值为00HADD AL, BL ;AL寄存器的值加上BL寄存器的值(温度个位数),得到温度值MOV AH, 50H ;将50H(80)装入AH寄存器CMP AL, AH ;比较AL和AH寄存器中值的大小JA ALMON ;若温度大于80,则跳转至ALMON,启动语音报警MOV AH, 4BH ;将4BH(75)装入AH寄存器CMP AL, AH ;比较AL和AH寄存器中值的大小JL ALMOFF ;若温度小于75,则跳转至ALMOFF,关闭语音报警,温度;取75的原因是避免实测温度值在80左右跳动引起报警系统的不稳定JMP DELAY0 ;跳转至DELAY0ALMON: ;启动语音报警MOV AL, 00H ;将00H装入AL寄存器OUT DX, AL ;向地址04B0H输出AL寄存器的值,即向语音录放模块的;PLAY输出低电平,开始回放事先录好的声音JMP DELAY0 ;跳转至DELAY0ALMOFF: ;关闭语音报警MOV AL, 0FFH ;将0FFH装入AL寄存器OUT DX, AL ;向地址04B0H输出AL寄存器的值,即向语音录放模块的;PLAY输出高电平,停止播放声音;=======语音报警模块结束=======DELAY0:MOV CX, 2710H ;将循环次数2710H装入CX寄存器DELAY1:NOPNOP ;空操作LOOP DELAY1 ;循环执行DELAY1,次数为2710H次JMP START ;跳转回START,循环执行程序SEGCOD DB3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71H;按顺序存放使数码管显示0到F的操作数V ALUETAB DB3CH,55H,71H,8DH,0A6H,0BBH,0CCH,0D8H,0E2H,0E9H,0EEH,0FFH;换算温度的数值表,由于热敏电阻具有非线性特性,因此需按数值表来换算得;出实际温度CODE ENDSEND START。

经典C语言源程序

经典C语言源程序

【程序1】题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?1.程序分析:可填在百位、十位、个位的数字都是1、2、3、4。

组成所有的排列后再去掉不满足条件的排列。

2.程序源代码:main(){int i,j,k;printf("\n");for(i=1;i<5;i++) /*以下为三重循环*/for(j=1;j<5;j++)for (k=1;k<5;k++){if (i!=k&&i!=j&&j!=k) /*确保i、j、k三位互不相同*/printf("%d,%d,%d\n",i,j,k);}}==============================================================【程序2】题目:企业发放的奖金根据利润提成。

利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?1.程序分析:请利用数轴来分界,定位。

注意定义时需把奖金定义成长整型。

2.程序源代码:main(){long int i;int bonus1,bonus2,bonus4,bonus6,bonus10,bonus;scanf("%ld",&i);bonus1=100000*0.1;bonus2=bonus1+100000*0.75;bonus4=bonus2+200000*0.5;bonus6=bonus4+200000*0.3;bonus10=bonus6+400000*0.15;if(i<=100000)bonus=i*0.1;else if(i<=200000)bonus=bonus1+(i-100000)*0.075;else if(i<=400000)bonus=bonus2+(i-200000)*0.05;else if(i<=600000)bonus=bonus4+(i-400000)*0.03;else if(i<=1000000)bonus=bonus6+(i-600000)*0.015;elsebonus=bonus10+(i-1000000)*0.01;printf("bonus=%d",bonus);}==============================================================【程序3】题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?1.程序分析:在10万以内判断,先将该数加上100后再开方,再将该数加上268后再开方,如果开方后的结果满足如下条件,即是结果。

语言处理程序基础(“源程序”文档)共4张

语言处理程序基础(“源程序”文档)共4张
第二次扫描的段任务。是产生目标程序。
用汇汇汇汇汇第汇汇第第汇汇汇汇用第解源汇用汇汇第 第用解汇编编编编编一编编一二编编编编汇一释程编汇编编一二汇释编 程 程 语 语 语 次 语 语 次 次 语 语 程 语 编 次 程 序 程 编 语 语 次次 编 程语序序言言言扫言言扫扫言言序言语扫序的序语言言扫 扫语序言的的源是是描源源描描是是的源言描是内的言是是描 描言是编基基程为为的程程的的为为基程编的另部基编为为的 的编另写本本序特特主序序主任特特本序写主一形本写特特主 任写一的工工由定定要由由要务定定工由的要种式工的定定要 务的种程作作若计计工若若工是计计作若程工语。作程计计工 是程语序包包干算算作干干作产算算包干序作言包序算算作 产序言称括括条机机是条条是生机机括条称是处括称机机是生称处为::语((定语语定目((:语为定理:为((定 目为理汇将将句或或义句句义标或或将句汇义程将汇或或义 标汇程编每每组计计符组组符程计计每组编符序每编计计符 程编序语一一成算算号成成号序算算一成语号,一语算算号 序语,言条条,机机的,,的。机机条,言的在条言机机的 。言在源可可一系系值一一值系系可一源值词可源系系值 源词程执执个统统并个个并统统执个程并法执程统统并 程法序行行程))创程程创))行程序创、行序))创 序、。汇汇序设设建序序建设设汇序。建语汇。设设建 。语编编中计计一中中一计计编中一法编计计一 法语语可的的个可可个的的语可个和语的的个 和句句以面面符以以符面面句以符语句面面符 语转转有向向号有有号向向转有号义转向向号 义换换三机机表三三表机机换三表分换机机表 分成成类器器类类器器成类析成器器析SSSSTTTT对对语的的语语的的对语方对的的方。。。。应应句符符句句符符应句面应符符面的的:号号::号号的:与的号号与机机指化化指指化化机指编机化化编器器令程程令令程程器令译器程程译指指语序序语语序序指语程指序序程令令句设设句句设设令句序令设设序::、计计、、计计:、的:计计的处处伪语语伪伪语语处伪工处语语工理理指言言指指言言理指作理言言作源源令。。令令。。源令原源。。原程程语语语程语理程理序序句句句序句基序基中中和和和中和本中本出出宏宏宏出宏相出相现现指指指现指同现同的 的 令 令 令 的 令 , 的 ,伪伪语语语伪语但伪但指指句句句指句是指是令令。。。令。在令在和和和运和运宏宏宏行宏行指指指用指用令令令户令户。。。程。程序序时时,,它它直直接接执执行行源源程程序序或或 源程序的内部形式。 第一次扫描的主要工作是定义符号的值并创建一个符号表ST。
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
double sum;
int i;
sum=0;
for(i=0;i<=L->length;i++)
sum=L->elem[i]*pow(x,i)+sum;
return sum;
}
void SUM(SqList *L,SqList *l,SqList *la){
int i;
}
break;
case 4:
printf("[%d,%d],f(x)>=g(x)\n",num[0],num[1]);
if(qz(L,num[4])>=qz(l,num[4]))
{ printf("[%d,%d],f(x)<=g(x)\n",num[2],num[4]);}
if (!l->elem) exit(OVERFLOW); // 存储分配失败
l->length = 0; // 空表长度为0
l->listsize = LIST_INIT_SIZE; // 初始存储容量
for(i=0;i<=l->listsize;i++) //为系数赋初值
printf("[%d,%d],f(x)<=g(x)\n",num[2],num[3]);
if(qz(L,num[6])>=qz(l,num[6]))
{ printf("[%d,%d],f(x)>=g(x)\n",num[4],num[6]);}
else
{
printf("[%d,%d],f(x)>=g(x)\n",num[4],num[5]);
{
printf("+");
};
e++;
}
}
void compare(SqList *L,SqList *l){//比较多项式大小函数
int num[9];
int e;
int x;
e=0;
x=0;
if(qz(L,x)>=qz(l,x))//此时x=0,此if判断0时f(x)>=g(x)否,确定好开头
}
break;
case 4:
printf("[%d,%d],f(x)<=g(x)\n",num[0],num[1]);
if(qz(L,num[4])<=qz(l,num[4]))
{ printf("[%d,%d],f(x)>=g(x)\n",num[2],num[4]);}
{ printf("[%d,%d],f(x)<=g(x)\n",num[0],num[2]);}
else
{
printf("[%d,%d],f(x)<=g(x)\n",num[0],num[1]);
printf("[%d],f(x)>=g(x)\n",num[2]);
num[2]=x;//f(x)<=g(x)
while((x<100)&&(qz(L,x)>=qz(l,x))){
x++;}
num[3]=x-1;
num[4]=x;
while((x<100)&&(qz(L,x)<=qz(l,x))){
x++;}
num[5]=x-1;
while(i<=L->length)
{ i++;
la->elem[i]=L->elem[i];//L比l多出部分
}
}
printf("f+g=");
while(e<=la->length)
{
printf("%dx^%d",la->elem[e],e);
if((e+1)<=la->length)
{ i++;
la->elem[i]=l->elem[i];//l比L多出部分
}
}
else
{
la->length=L->length;
do{
la->elem[i]=l->elem[i]+L->elem[i];
i++;}while(i<=l->length);
else
{
printf("[%d,%d],f(x)<=g(x)\n",num[2],num[3]);
printf("[%d],f(x)>=g(x)\n",num[4]);
}
break;
case 6:
printf("[%d,%d],f(x)>=g(x)\n",num[0],num[1]);
else
{
printf("[%d,%d],f(x)>=g(x)\n",num[2],num[3]);
printf("[%d],f(x)<=g(x)\n",num[4]);
}
break;
case 6:
printf("[%d,%d],f(x)<=g(x)\n",num[0],num[1]);
源程序及注释:
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
#define OK 1
#define OVERFLOW 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
L->elem[i]=temp;
else
exit(0);
}while (getchar()!=ength=i;
}// getf
void ds(SqList *L,SqList *l){//多项式求导函数
int e;
int i=1;
while(i<=L->length)
{
l->elem[i-1]=i*L->elem[i];//(A*x^i)'=A*i*x^(i-1)
e=i-1;
printf("%dx^%d",l->elem[i-1],e);
if((i+1)<=L->length)
{
num[6]=x;
while((x<100)&&(qz(L,x)>=qz(l,x))){
x++;}
num[7]=x-1;
num[8]=x;
while(num[e]!=100){
e=e+2;}
switch(e)
{
case 2:
if(qz(L,num[2])<=qz(l,num[2]))
l->elem[i]=0;
return OK;
}// InitList_Sq
void getf(SqList *L){//获取多项式函数
int temp;
int i;
do{
scanf("%d%d",&temp,&i);
if (i<L->listsize)
printf("[%d,%d],f(x)>=g(x)\n",num[2],num[3]);
if(qz(L,num[6])<=qz(l,num[6]))
{ printf("[%d,%d],f(x)<=g(x)\n",num[4],num[6]);}
else
{
printf("[%d,%d],f(x)<=g(x)\n",num[4],num[5]);
printf("[%d],f(x)<=g(x)\n",num[6]);
}
break;
case 8:
printf("[%d,%d],f(x)>=g(x)\n",num[0],num[1]);
printf("[%d,%d],f(x)<=g(x)\n",num[2],num[3]);
printf("+");
};
i++;
}
l->length=L->length-1;
}
void fd(SqList *L,SqList *l){//多项式求积分函数
int e;
int i=0;
while(i<=L->length){
l->elem[i+1]=L->elem[i]/(i+1);
{
num[0]=x;
while((x<100)&&(qz(L,x)>=qz(l,x))){//跳出循环即大小变号了
x++;}
num[1]=x-1;//f(x)>=g(x)
相关文档
最新文档