Location:
Search - k val
Search list
Description: /*PL/0编译系统C版本头文件pl0.h*/
/*
typedef enum
{
false,
true
} bool;
*/
#define norw 13 /*关键字个数*/
#define txmax 100 /*名字表容量*/
#define nmax 14 /*number的最大位数*/
#define al 10 /*符号的最大长度*/
#define amax 2047 /*地址上界*/
#define levmax 3 /*最大允许过程嵌套声明层数[0,levmax]*/
#define cxmax 200 /*最多的虚拟机代码数*/
/*符号*/
enum symbol{
nul, ident, number, plus, minus,
times, slash, oddsym, eql, neq,
lss, leq, gtr, geq, lparen,
rparen, comma, semicolon, period, becomes,
beginsym, endsym, ifsym, thensym, whilesym,
writesym, readsym, dosym, callsym, constsym,
varsym, procsym,
};
#define symnum 32
/*名字表中的类型*/
enum object{
constant,
variable,
procedur,
};
/*虚拟机代码*/
enum fct{
lit, opr, lod,
sto, cal, inte,
jmp, jpc,
};
#define fctnum 8
/*虚拟机结构代码*/
struct instruction
{
/*454*/
enum fct f; // 虚拟机代码指令
int l; //引用层与声明层的层次差
int a; //根据f的不同而不同
};
FILE * fas; //输出名字表
FILE * fa; //输出虚拟机代码
FILE * fa1; //输出源文件及其各行对应的首地址
FILE * fa2; //输出结果
bool listswitch; //显示虚拟机代码与否
bool tableswitch; //显示名字与否
char ch; //获取字符的缓冲区,getch使用
enum symbol sym; //当前的符号
char id[al+1]; //当前ident,多出的一个字节用于存放0
int num; //当前number
int cc,ll; //getch使用的计数器,cc表示当前字符(ch)的位置
int cx; //虚拟机代码指针,取值范围[0,cxmax-1]
char line[81]; //读取行缓冲区
char a[al+1]; //临时符号,多出的一个字节用于存放0
struct instruction code[cxmax]; //存放虚拟机代码的数组
char word[norw][al]; //保留字
enum symbol wsym[norw]; //保留字对应的符号值
enum symbol ssym[256]; //单字符的符号值
char mnemonic[fctnum][5]; //虚拟机代码指令名称
bool declbegsys[symnum]; //表示声明开始的符号集合
bool statbegsys[symnum]; //表示语句开始的符号集合
bool facbegsys[symnum]; //表示因子开始的符号集合
//名字表结构
struct tablestruct
{
char name[al]; //名字
enum object kind; //类型:const,var,array or procedure
int val; //数值,仅const使用
int level; //所须层,仅const不能用
int adr; //地址,仅const不能用
int size; //需要分配的数据空间,仅procedure使用
};
struct tablestruct table[txmax]; //名字表
FILE * fin;
FILE * fout;
char fname[al];
int err; //错误计数器
//当函数中发生fatal error时,返回-1告知调用它的函数,最终退出程序
#define getsymdo if(-1==getsym()) return -1
#define getchdo if(-1==getch()) return -1
#define testdo(a,b,c) if(-1==test(a,b,c)) return -1
#define gendo(a,b,c) if(-1==gen(a,b,c)) return -1
#define expressiondo(a,b,c) if(-1==expression(a,b,c)) return -1
#define factordo(a,b,c) if(-1==factor(a,b,c)) return -1
#define termdo(a,b,c) if(-1==term(a,b,c)) return -1
#define conditiondo(a,b,c) if(-1==condition(a,b,c)) return -1
#define statementdo(a,b,c) if(-1==statement(a,b,c)) return -1
#define constdeclarationdo(a,b,c) if(-1==constdeclaration(a,b,c)) return -1
#define vardeclarationdo(a,b,c) if(-1==vardeclaration(a,b,c)) return -1
void error(int n);
int getsym();
int getch();
void init();
int gen(enum fct x,int y ,int z);
int test(bool *s1,bool *s2,int n);
int inset(int e,bool *s);
int addset(bool *str,bool * s1,bool * s2,int n);
int subset(bool *str,bool * s1,bool * s2,int n);
int mulset(bool *str,bool * s1,bool * s2,int n);
int block(int lev,int tx,bool * fsys);
void interpret();
int factor(bool * fsys,int * ptx,int lev);
int term(bool * fsys,int * ptx,int lev);
int condition(bool * fsys,int * ptx,int lev);
int expression(bool * fsys,int * ptx,int lev);
int statement(bool * fsys,int * ptx,int lev);
void listcode(int cx0);
int vardeclaration(int *ptr, int lev,int *ptx);
int constdeclaration(int *ptr, int lev,int *ptx);
int position(char * idt,int tx);
void enter(enum object k,int * ptx,int lev, int * pdx);
int base(int l,int * s,int b)
Platform: |
Size: 25139 |
Author: xqq771084591 |
Hits:
Description: Private Sub Command1_Click()
strtmp = Text1.Text
nlen = Len(strtmp)
k = 1
For i = 1 To nlen
j = Asc(Mid(strtmp, i, 1))
If j < 47 Or j > 58 Then
k = 2
End If
Next i
If k <> 2 Then
Text2.Text = Val(Text1.Text) Xor &H11677831
Else
e = MsgBox(\"你输入的机器码有误,请重新输入!\", 0, \"Error!!!\")
End If
End Sub
Private Sub Command2_Click()
aa = MsgBox(\"逆风飞扬电脑工作室倾力制作\", 0, \"退出\")
Unload Me
End Sub
-Private Sub Command1_Click () strtmp = Text1.Text nlen = Len (strtmp) k = 1 For i = 1 To nlen j = Asc (Mid (strtmp, i, 1)) If j
Platform: |
Size: 145408 |
Author: WEI |
Hits:
Description: 综合了数据挖掘的均值算法和中值算法,带有一个小的测试数据集合-data mining algorithm intergrated
Platform: |
Size: 126976 |
Author: liu |
Hits:
Description: vb编写的高斯消去法,通用函数,如有不好的地方,还请指教!-Dim a(), b(), n, k, l 定义必须的通用变量
Private Sub Command1_Click()
If k = n Then
Command1.Enabled = False
Text2.Enabled = False
Else
k = k+ 1
Text2 = ""
End If
End Sub
Private Sub Command2_Click()
If l = n Then
Text3.Enabled = False
Else
l = l+ 1
Text2 = ""
Text3 = ""
Command1.Enabled = True
Text2.Enabled = True
End If
End Sub
Private Sub Command3_Click() 求解方程组
Dim m()
ReDim m(1 To n, 1 To n)
For i = 1 To n- 1
For j = i+ 1 To n
m(j, i) = a(j, i)/a(i, i)
End Sub
Private Sub Form_Activate()
k = 1
l = 1
Picture1.Print "系数"
End Sub
Private Sub Text1_Change() 指定方程组元数
n = Val(Text1)
ReDim a(1 To n, 1 To n)
ReDim b(1 To n)
End Sub
Private Sub Text2_Change() 给方程组各系数Aij赋值
a(k, l) = Val(Text2)
Picture1.Print a(k, l) & ","
End Sub
Private Sub Text3_Change() 给方程组系数Bi赋值
b(l) = Val(Text3)
Picture1.Print b(l) & ","
End Sub
Platform: |
Size: 2048 |
Author: chubby |
Hits:
Description: Drunbee 非常喜欢狗狗,他有 n 只狗,每只狗都有一个忠诚度 val。午饭时间,n 只狗
会排成一行,编号 1~n。Drunbee 每次会选择一个区间,从区间中选择忠诚度第 k 小的狗喂
食,你能告诉他区间忠诚度第 k 小的狗的忠诚度是多少吗? ★数据输入
输入第一行为两个正整数 n、m。表示有 n 只狗,m 次喂食。
接下来一行,有 n 个整数,依次是第一只狗的忠诚度,第二只狗的忠诚度,……,第 n 只狗的忠诚度。
接下来 m 行,每行三个整数 x,y,k,表示询问区间[x,y]的第 k 小的忠诚度是多少。
数据保证每次询问的区间可能会相交,但是任意两个不会相互包含,询问都合法。
n<=10^5,m<=5*10^4,val<=10^9 ★数据输出
对于每个询问,输出一行一个整数,表示所求的忠诚度。 输入示例 输出示例
7 2
1 5 2 6 3 7 4
2 7 3
1 5 3
4
3-Drunbee very fond of the dog, he n dogs, every dog has a loyalty val. The lunchtime, n dogs will line up, the No. 1 ~~ n. Drunbee each will select a range, from to choose loyalty k small dog interval feeding, you can tell he interval loyalty k small dog' s loyalty is how much you? ★ data input input behavior first two positive integers n, m. M times fed n dogs. The next line, n integer, followed by the first loyalty of dogs, dogs loyalty, ......, the dogs n loyalty. Next m rows, each three integers x, y, k, indicates the the inquired interval [x, y] of the k-th small loyalty. Data to ensure that each query interval may intersect, but any two not mutually inclusive asking are legitimate. n < = 10 ^ 5 m < = 5* 10 ^ 4 val < = 10 ^ 9 ★ data output for each inquiry line of output is an integer that indicates the demand loyalty. Enter the sample output of Example 7 2 1 5 2 6 3 7 4 2 7 3 1 5 3 4 3
Platform: |
Size: 1024 |
Author: 陈和 |
Hits:
Description: 功能:用DFP算法求解无约束问题
输入:X0是初始点,fun,gfun分别是目标函数及其梯度
输出:x,val分别是近似最优点和最优值,k是迭代次数-Davidon-Fletcher-Powell method for optimization.
Platform: |
Size: 1024 |
Author: AllenBenge |
Hits:
Description: 功能:牛顿型信赖域方法求解无约束优化问题min f(x)
输入 x0是初始迭代点
输出:xk是近似极小点,val是近似极小值,k是迭代次数- function: Newton type trust region method for solving unconstrained optimization problem min f (x)
input The xo is the initial iteration point
output: xk is approximate minimum point, val is approximate minimum, k is the number of iterations
Platform: |
Size: 3072 |
Author: 苗小楠 |
Hits:
Description: 功能:用FR共轭梯度法求解无约束问题:min f(x)
输入:x0是初始点,fun,gfun分别是目标函数和梯度
输出:x,val分别是近似最优点和最优值,k是迭代次数-Features: use FR conjugate gradient method to solve the unconstrained problem: min f (x)
input: x0 is the initial point, fun, gfun is the objective function and the gradient, respectively
output: x, val is approximate optimal point and the optimal value respectively, k is the number of iterations
Platform: |
Size: 2048 |
Author: 苗小楠 |
Hits:
Description: function[x,val,k] dampnm(fun,gfun,hesse,x0)
功能:用阻尼牛顿法求解无约束问题:min f(x)
输入:x0是初始点,fun,gfun,hesse分别是目标函数值,梯度,hesse矩阵的函数
输出:x,val分别是近似最优点和最优值,k是迭代次数-The function/x, val, k dampnm (fun, gfun, Hesse, x0)
function: with damped Newton method for solving unconstrained problem: min f (x)
input: x0 is the initial point, fun, gfun, Hesse is the objective function value respectively, gradient, Hesse matrix function
output: x, val is approximate optimal point and the optimal value respectively, k is the number of iterations
Platform: |
Size: 2048 |
Author: 苗小楠 |
Hits:
Description: 功能:用BFGS算法求解无约束问题:min f(x)
输入:x0是初始点,fun,gfun分别是目标函数及其梯度;
varargin是输入可变参数变量,简单调用bfgs时可以忽略它,
但是其他程序循环调用时将会发挥重要作用
输出:x,val分别是近似最优点和最优值,k是迭代次数。-Function: BFGS algorithm for unconstrained problem: min f (x) Input: X0 is the initial point, fun, gfun each objective function and its gradient varargin variable parameter is the input variable, it can be ignored when a simple call bfgs , but other programs will play an important role when the cycle is called output: x, val are approximate optimum and the optimal value, k is the number of iterations.
Platform: |
Size: 2048 |
Author: 杨静 |
Hits:
Description: 字符串比较问题
问题分析:解答此题需要一个较为巧妙的解题思路。解决此题可以借用“最长公共子串”问题的解题思路。采用自底向上的动态规划思想。假设对于给定的字符串A,B长度分别为m,n,A[1..m],B[1..n],这里可以使用变量val[m][n]表示A,B的扩展距离。
对于字符串A[1..m],B[1..n],有以下两种情况:
1.A[m]和B[n]处在扩展字符串的同一个位置,那么val[m][n]=val[m-1][n-1]+abs(A[m]-B[n])。
2.A[m]和B[n]不在扩展字符串的同一个位置,则val[m][n]=min{val[m-1][n]+k,val[m][n-1]+k}。
综上,val[m][n]=min{val[m-1][n]+k,val[m][n-1]+k,val[m-1][n-1]+abs(A[m]-B[n])}
由上述递推式,采用自底向上的方法在多项式时间内即可求出val[m][n](String comparison problem)
Platform: |
Size: 273408 |
Author: mazr
|
Hits: