├── .gitignore
├── MyCompiler.sln
├── MyCompiler
├── 15061129_test.txt
├── Compiler.cpp
├── Compiler.h
├── MyCompiler.vcxproj
├── MyCompiler.vcxproj.filters
├── _dag图以及小优化调试信息.txt
├── _优化前中间代码.txt
├── _优化后中间代码.txt
├── _基本块划分情况.txt
├── _数据流分析信息.txt
├── _符号表信息.txt
├── errorHandler.cpp
├── errorHandler.h
├── grammar.cpp
├── main.cpp
├── midcode.cpp
├── midcode.h
├── objectCode.cpp
├── objectCode.h
├── optimization.cpp
├── optimization.h
├── randomToUpper.cpp
├── stdafx.cpp
├── stdafx.h
├── symbolTab.cpp
├── symbolTab.h
├── targetver.h
├── test.cpp
├── token.cpp
├── token.h
├── warningHandler.cpp
└── warningHandler.h
├── README.md
├── 文档
├── 15061129_解小锐_申优文章.docx
├── 15061129_解小锐_编译技术设计文档.docx
├── 性能分析
│ ├── C16 8 优化前.jpg
│ ├── C16 8 优化后.jpg
│ ├── dag优化前.jpg
│ ├── dag优化前2.jpg
│ ├── dag优化后.jpg
│ ├── dag优化后2.jpg
│ ├── 老师代码 三次优化后.jpg
│ ├── 老师代码 二次优化后.jpg
│ ├── 老师代码 优化前.jpg
│ └── 老师代码 优化后.jpg
├── 整体结构
│ ├── 优化流程.png
│ └── 程序整体结构.png
├── 词法分析
│ └── 词法分析.png
└── 语法流程图
│ ├── _主函数定义_.png
│ ├── _值参数表_.png
│ ├── _写语句_.png
│ ├── _参数_.png
│ ├── _变量定义处理_.png
│ ├── _变量说明_.png
│ ├── _可能以函数定义开始的程序_.png
│ ├── _可能以变量开始的程序_.png
│ ├── _因子_.png
│ ├── _声明头部_.png
│ ├── _复合语句_.png
│ ├── _常量_.png
│ ├── _常量定义_.png
│ ├── _常量说明_.png
│ ├── _循环语句_.png
│ ├── _情况子语句_.png
│ ├── _情况表_.png
│ ├── _情况语句_.png
│ ├── _数组赋值处理_.png
│ ├── _整数_.png
│ ├── _无参函数定义处理_.png
│ ├── _普通无返回值函数定义_.png
│ ├── _有参函数定义处理_.png
│ ├── _条件_.png
│ ├── _条件语句_.png
│ ├── _程序_.png
│ ├── _简单赋值处理_.png
│ ├── _表达式_.png
│ ├── _语句_.png
│ ├── _语句列_.png
│ ├── _读语句_.png
│ ├── _返回语句_.png
│ ├── _项_.png
│ └── 未命名文件.png
└── 测试文件
├── 0
├── ans_awh.txt
├── ans_jjh.txt
├── ans_lx.txt
├── ans_null.txt
├── ans_wyc.txt
├── ans_ycy.txt
├── ans_yww.txt
├── ans_zf.txt
├── ans_zhw.txt
├── test_awh.txt
├── test_jjh.txt
├── test_lx.txt
├── test_null.txt
├── test_wyc.txt
├── test_ycy.txt
├── test_yww.txt
├── test_zf.txt
└── test_zhw.txt
├── 15061129_test.txt
├── error0.txt
├── error1.txt
├── error2.txt
├── error3.txt
├── error4.txt
└── error5.txt
/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/.gitignore
--------------------------------------------------------------------------------
/MyCompiler.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyCompiler", "MyCompiler\MyCompiler.vcxproj", "{997FB3A3-3B3F-4C47-ABF9-47E646174420}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {997FB3A3-3B3F-4C47-ABF9-47E646174420}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {997FB3A3-3B3F-4C47-ABF9-47E646174420}.Debug|Win32.Build.0 = Debug|Win32
14 | {997FB3A3-3B3F-4C47-ABF9-47E646174420}.Release|Win32.ActiveCfg = Release|Win32
15 | {997FB3A3-3B3F-4C47-ABF9-47E646174420}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/MyCompiler/15061129_test.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/15061129_test.txt
--------------------------------------------------------------------------------
/MyCompiler/Compiler.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/Compiler.cpp
--------------------------------------------------------------------------------
/MyCompiler/Compiler.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/Compiler.h
--------------------------------------------------------------------------------
/MyCompiler/MyCompiler.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {997FB3A3-3B3F-4C47-ABF9-47E646174420}
15 | Win32Proj
16 | MyCompiler
17 |
18 |
19 |
20 | Application
21 | true
22 | Unicode
23 |
24 |
25 | Application
26 | false
27 | true
28 | Unicode
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | true
42 |
43 |
44 | false
45 |
46 |
47 |
48 |
49 |
50 | Level3
51 | Disabled
52 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
53 |
54 |
55 | Console
56 | true
57 |
58 |
59 |
60 |
61 | Level3
62 |
63 |
64 | MaxSpeed
65 | true
66 | true
67 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
68 |
69 |
70 | Console
71 | true
72 | true
73 | true
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/MyCompiler/MyCompiler.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | 源文件
20 |
21 |
22 | 源文件
23 |
24 |
25 | 源文件
26 |
27 |
28 | 源文件
29 |
30 |
31 | 源文件
32 |
33 |
34 | 源文件
35 |
36 |
37 | 源文件
38 |
39 |
40 | 源文件
41 |
42 |
43 | 源文件
44 |
45 |
46 | 源文件
47 |
48 |
49 | 源文件
50 |
51 |
52 | 源文件
53 |
54 |
55 | 源文件
56 |
57 |
58 |
59 |
60 | 头文件
61 |
62 |
63 | 头文件
64 |
65 |
66 | 头文件
67 |
68 |
69 | 头文件
70 |
71 |
72 | 头文件
73 |
74 |
75 | 头文件
76 |
77 |
78 | 头文件
79 |
80 |
81 | 头文件
82 |
83 |
84 | 头文件
85 |
86 |
87 | 头文件
88 |
89 |
90 |
--------------------------------------------------------------------------------
/MyCompiler/_dag图以及小优化调试信息.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/_dag图以及小优化调试信息.txt
--------------------------------------------------------------------------------
/MyCompiler/_优化前中间代码.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/_优化前中间代码.txt
--------------------------------------------------------------------------------
/MyCompiler/_优化后中间代码.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/_优化后中间代码.txt
--------------------------------------------------------------------------------
/MyCompiler/_基本块划分情况.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/_基本块划分情况.txt
--------------------------------------------------------------------------------
/MyCompiler/_数据流分析信息.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/_数据流分析信息.txt
--------------------------------------------------------------------------------
/MyCompiler/_符号表信息.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/_符号表信息.txt
--------------------------------------------------------------------------------
/MyCompiler/errorHandler.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/errorHandler.cpp
--------------------------------------------------------------------------------
/MyCompiler/errorHandler.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/errorHandler.h
--------------------------------------------------------------------------------
/MyCompiler/grammar.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/grammar.cpp
--------------------------------------------------------------------------------
/MyCompiler/main.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/main.cpp
--------------------------------------------------------------------------------
/MyCompiler/midcode.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/midcode.cpp
--------------------------------------------------------------------------------
/MyCompiler/midcode.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/midcode.h
--------------------------------------------------------------------------------
/MyCompiler/objectCode.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/objectCode.cpp
--------------------------------------------------------------------------------
/MyCompiler/objectCode.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/objectCode.h
--------------------------------------------------------------------------------
/MyCompiler/optimization.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/optimization.cpp
--------------------------------------------------------------------------------
/MyCompiler/optimization.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/optimization.h
--------------------------------------------------------------------------------
/MyCompiler/randomToUpper.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/randomToUpper.cpp
--------------------------------------------------------------------------------
/MyCompiler/stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/stdafx.cpp
--------------------------------------------------------------------------------
/MyCompiler/stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/stdafx.h
--------------------------------------------------------------------------------
/MyCompiler/symbolTab.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/symbolTab.cpp
--------------------------------------------------------------------------------
/MyCompiler/symbolTab.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/symbolTab.h
--------------------------------------------------------------------------------
/MyCompiler/targetver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/targetver.h
--------------------------------------------------------------------------------
/MyCompiler/test.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/test.cpp
--------------------------------------------------------------------------------
/MyCompiler/token.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/token.cpp
--------------------------------------------------------------------------------
/MyCompiler/token.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/token.h
--------------------------------------------------------------------------------
/MyCompiler/warningHandler.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/warningHandler.cpp
--------------------------------------------------------------------------------
/MyCompiler/warningHandler.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/MyCompiler/warningHandler.h
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BUAA Compiler Work
2 |
3 | 北航编译课程设计要做的小编译器
4 |
5 | C0难度文法,最后成绩98分
6 |
7 | ### 1. 文法说明
8 |
9 | 这次获取到的文法是C0难度的文法,具体文法详细信息如下:
10 |
11 | <加法运算符> ::= +|-
12 |
13 | <乘法运算符> ::= *|/
14 |
15 | <关系运算符> ::= <|<=|>|>=|!=|==
16 |
17 | <字母> ::= _|a|...|z|A|...|Z
18 |
19 | <数字> ::= 0|<非零数字>
20 |
21 | <非零数字> ::= 1|...|9
22 |
23 | <字符> ::= '<加法运算符>'|'<乘法运算符>'|'<字母>'|'<数字>'
24 |
25 | <字符串> ::= "{十进制编码为32,33,35-126的ASCII字符}"
26 |
27 | <程序> ::= [<常量说明>][<变量说明>]{<有返回值函数定义>|<无返回值函数定义>}<主函数>
28 |
29 | <常量说明> ::= const<常量定义>;{ const<常量定义>;}
30 |
31 | <常量定义> ::= int<标识符>=<整数>{,<标识符>=<整数>} | char<标识符>=<字符>{,<标识符>=<字符>}
32 |
33 | <无符号整数> ::= <非零数字>{<数字>}
34 |
35 | <整数> ::= [+|-]<无符号整数>|0
36 |
37 | <标识符> ::= <字母>{<字母>|<数字>}
38 |
39 | <声明头部> ::= int<标识符> |char<标识符>
40 |
41 | <变量说明> ::= <变量定义>;{<变量定义>;}
42 |
43 | <变量定义> ::= <类型标识符>(<标识符>|<标识符>‘[’<无符号整数>‘]’){,(<标识符>|<标识符>‘[’<无符号整数>‘]’ )}
44 |
45 | <常量> ::= <整数>|<字符>
46 |
47 | <类型标识符> ::= int | char
48 |
49 | <有返回值函数定义> ::= <声明头部>‘(’<参数>‘)’ ‘{’<复合语句>‘}’|<声明头部>‘{’<复合语句>‘}’ //第一种选择为有参数的情况,第二种选择为无参数的情况
50 |
51 | <无返回值函数定义> ::= void<标识符>(’<参数>‘)’‘{’<复合语句>‘}’| void<标识符>{’<复合语句>‘}’//第一种选择为有参数的情况,第二种选择为无参数的情况
52 |
53 | <复合语句> ::= [<常量说明>][<变量说明>]<语句列>
54 |
55 | <参数> ::= <参数表>
56 |
57 | <参数表> ::= <类型标识符><标识符>{,<类型标识符><标识符>}
58 |
59 | <主函数> ::= void main‘(’‘)’‘{’<复合语句>‘}’
60 |
61 | <表达式> ::= [+|-]<项>{<加法运算符><项>}
62 |
63 | <项> ::= <因子>{<乘法运算符><因子>}
64 |
65 | <因子> ::= <标识符>|<标识符>‘[’<表达式>‘]’|‘(’<表达式>‘)’|<整数>|<字符>|<有返回值函数调用语句>
66 |
67 | <语句> ::= <条件语句>|<循环语句>| ‘{’<语句列>‘}’|<有返回值函数调用语句>; |<无返回值函数调用语句>;|<赋值语句>;|<读语句>;|<写语句>;|<空>;|<情况语句>|<返回语句>;
68 |
69 | <赋值语句> ::= <标识符>=<表达式>|<标识符>‘[’<表达式>‘]’=<表达式>
70 |
71 | <条件语句>::= if ‘(’<条件>‘)’<语句>else<语句>
72 |
73 | <条件> ::= <表达式><关系运算符><表达式>|<表达式> //表达式为0条件为假,否则为真
74 |
75 | <循环语句> ::= while ‘(’<条件>‘)’<语句>
76 |
77 | <情况语句> ::= switch ‘(’<表达式>‘)’ ‘{’<情况表>[<缺省>] ‘}’
78 |
79 | <情况表> ::= <情况子语句>{<情况子语句>}
80 |
81 | <情况子语句> ::= case<常量>:<语句>
82 |
83 | <缺省> ::= default : <语句>
84 |
85 | <有返回值函数调用语句> ::= <标识符>‘(’<值参数表>‘)’|<标识符> //第一种选择为有参数的情况,第二种选择为无参数的情况
86 |
87 | <无返回值函数调用语句> ::= <标识符>‘(’<值参数表>‘)’|<标识符> //第一种选择为有参数的情况,第二种选择为无参数的情况
88 |
89 | <值参数表> ::= <表达式>{,<表达式>}
90 |
91 | <语句列> ::= {<语句>}
92 |
93 | <读语句> ::= scanf ‘(’<标识符>{,<标识符>}‘)’
94 |
95 | <写语句> ::= printf ‘(’ <字符串>,<表达式> ‘)’| printf ‘(’<字符串> ‘)’| printf ‘(’<表达式>‘)’
96 |
97 | <返回语句> ::= return[‘(’<表达式>‘)’]
98 |
99 | 附加说明:
100 |
101 | (1)char类型的表达式,用字符的ASCII码对应的整数参加运算,在写语句中输出字符
102 |
103 | (2)标识符不区分大小写字母
104 |
105 | (3)写语句中的字符串原样输出
106 |
107 | (4)情况语句中,switch后面的表达式和case后面的常量只允许出现int和char类型;每个情况子语句执行完毕后,不继续执行后面的情况子语句
108 |
109 | (5)数组的下标从0开始
110 |
111 | ## 2. 程序输入输出说明
112 |
113 | 运行程序,控制台输入要编译的程序文件路径,回车后会输出8个文件,每个文件的作用可以通过看`设计文档`的`操作步骤`部分查看
114 |
115 | ## 3. 优化说明
116 |
117 | 我做了如下优化:
118 |
119 | 1. 基本块内dag图公共子表达式优化
120 | 2. 通过活跃变量分析,利用dag图算法删除无用变量,并构建冲突图,进行寄存器分配
121 | 3. 一些关于多余跳转和多余label的删除
122 |
123 | ## 4. 相关总结
124 |
125 | 我写了一些我的心得在`设计文档`以及`申优文章`中
126 |
127 | ## 5. 文件夹说明
128 |
129 | `测试文件`中包含了一些测试文件,,`文档`中包含了所有的文档
--------------------------------------------------------------------------------
/文档/15061129_解小锐_申优文章.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/15061129_解小锐_申优文章.docx
--------------------------------------------------------------------------------
/文档/15061129_解小锐_编译技术设计文档.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/15061129_解小锐_编译技术设计文档.docx
--------------------------------------------------------------------------------
/文档/性能分析/C16 8 优化前.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/C16 8 优化前.jpg
--------------------------------------------------------------------------------
/文档/性能分析/C16 8 优化后.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/C16 8 优化后.jpg
--------------------------------------------------------------------------------
/文档/性能分析/dag优化前.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/dag优化前.jpg
--------------------------------------------------------------------------------
/文档/性能分析/dag优化前2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/dag优化前2.jpg
--------------------------------------------------------------------------------
/文档/性能分析/dag优化后.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/dag优化后.jpg
--------------------------------------------------------------------------------
/文档/性能分析/dag优化后2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/dag优化后2.jpg
--------------------------------------------------------------------------------
/文档/性能分析/老师代码 三次优化后.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/老师代码 三次优化后.jpg
--------------------------------------------------------------------------------
/文档/性能分析/老师代码 二次优化后.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/老师代码 二次优化后.jpg
--------------------------------------------------------------------------------
/文档/性能分析/老师代码 优化前.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/老师代码 优化前.jpg
--------------------------------------------------------------------------------
/文档/性能分析/老师代码 优化后.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/性能分析/老师代码 优化后.jpg
--------------------------------------------------------------------------------
/文档/整体结构/优化流程.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/整体结构/优化流程.png
--------------------------------------------------------------------------------
/文档/整体结构/程序整体结构.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/整体结构/程序整体结构.png
--------------------------------------------------------------------------------
/文档/词法分析/词法分析.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/词法分析/词法分析.png
--------------------------------------------------------------------------------
/文档/语法流程图/_主函数定义_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_主函数定义_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_值参数表_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_值参数表_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_写语句_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_写语句_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_参数_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_参数_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_变量定义处理_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_变量定义处理_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_变量说明_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_变量说明_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_可能以函数定义开始的程序_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_可能以函数定义开始的程序_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_可能以变量开始的程序_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_可能以变量开始的程序_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_因子_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_因子_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_声明头部_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_声明头部_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_复合语句_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_复合语句_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_常量_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_常量_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_常量定义_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_常量定义_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_常量说明_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_常量说明_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_循环语句_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_循环语句_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_情况子语句_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_情况子语句_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_情况表_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_情况表_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_情况语句_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_情况语句_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_数组赋值处理_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_数组赋值处理_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_整数_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_整数_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_无参函数定义处理_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_无参函数定义处理_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_普通无返回值函数定义_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_普通无返回值函数定义_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_有参函数定义处理_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_有参函数定义处理_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_条件_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_条件_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_条件语句_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_条件语句_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_程序_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_程序_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_简单赋值处理_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_简单赋值处理_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_表达式_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_表达式_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_语句_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_语句_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_语句列_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_语句列_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_读语句_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_读语句_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_返回语句_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_返回语句_.png
--------------------------------------------------------------------------------
/文档/语法流程图/_项_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/_项_.png
--------------------------------------------------------------------------------
/文档/语法流程图/未命名文件.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/文档/语法流程图/未命名文件.png
--------------------------------------------------------------------------------
/测试文件/0/ans_awh.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/0/ans_awh.txt
--------------------------------------------------------------------------------
/测试文件/0/ans_jjh.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/0/ans_jjh.txt
--------------------------------------------------------------------------------
/测试文件/0/ans_lx.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/0/ans_lx.txt
--------------------------------------------------------------------------------
/测试文件/0/ans_null.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/0/ans_null.txt
--------------------------------------------------------------------------------
/测试文件/0/ans_wyc.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/0/ans_wyc.txt
--------------------------------------------------------------------------------
/测试文件/0/ans_ycy.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/0/ans_ycy.txt
--------------------------------------------------------------------------------
/测试文件/0/ans_yww.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/0/ans_yww.txt
--------------------------------------------------------------------------------
/测试文件/0/ans_zf.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/0/ans_zf.txt
--------------------------------------------------------------------------------
/测试文件/0/ans_zhw.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/0/ans_zhw.txt
--------------------------------------------------------------------------------
/测试文件/0/test_awh.txt:
--------------------------------------------------------------------------------
1 | const int a = +5;
2 | const char m = '3';
3 | const int z = 6,b = 10;
4 | CONST char q = 's',p = 't';
5 |
6 | int ss[1];
7 | char str_test[50];
8 | int number[30],ans[30];
9 | int ra,rb,rc,rd;
10 |
11 | void defi(int value){
12 | const char D1 = 'd',E1 = 'e',F1 = 'f',G1 = '+',H1 = '-';
13 | const char I1 = '8';
14 |
15 | int a,b,c,d[10],e[4],f;
16 | int m[7],n[8],p,q,h[9];
17 | char i,o[4],r[5],s,t,u[65],v___;
18 |
19 | a = value;
20 | d[5] = value;
21 | a = D1;
22 | v___ = G1;
23 |
24 | printf("variable and const defination passed!");
25 | }
26 |
27 | void defi_test{
28 | defi(66);
29 | }
30 |
31 |
32 | int max(int a,int b){
33 | if(a > b)
34 | return (a);
35 | else{}
36 | if(b > a)
37 | return (b);
38 | else{}
39 | return (((a) - (-b)) / 2);
40 | }
41 |
42 | void fun_def_test{
43 | int c;
44 | c = max(max(max(5,+5),5),5);
45 | printf("c is ",c);
46 | }
47 |
48 | int calcu(int size){
49 | int i;
50 | int sum;
51 | i = 0;
52 | sum = 0;
53 |
54 |
55 | sum = sum + number[i];
56 | i = i + 1;
57 | while(i < size){
58 | sum = sum + number[i];
59 | i = i + 1;
60 | }
61 | return (sum);
62 | }
63 |
64 |
65 | int calcuCov(int size,int aver){
66 | int i;
67 | int cov;
68 | int temp;
69 | i = 0;
70 | cov = 0;
71 | temp = ((number[i] - aver) * (number[i] - aver));
72 | cov = cov + temp;
73 | i = i + 1;
74 | while(i < size){
75 | temp = ((number[i] - aver) * (number[i] - aver));
76 | cov = cov + temp;
77 | i = i + 1;
78 | }
79 | return (cov);
80 | }
81 |
82 | int partion(int sta,int end){
83 | int x,temp;
84 | int i,j;
85 | x = number[end];
86 | i = sta - 1;
87 | j = sta;
88 | if(number[j] <= x){
89 | i = i + 1;
90 | temp = number[i];
91 | number[i] = number[j];
92 | number[j] = temp;
93 | }else{}
94 | j = j + 1;
95 | while(j < end){
96 | if(number[j] <= x){
97 | i = i + 1;
98 | temp = number[i];
99 | number[i] = number[j];
100 | number[j] = temp;
101 | }else{}
102 | j = j + 1;
103 | }
104 |
105 | temp = number[i + 1];
106 | number[i + 1] = number[end];
107 | number[end] = temp;
108 | return (i+1);
109 | }
110 |
111 | void quick_sort(int sta,int end){
112 | int q;
113 | if(sta < end){
114 | q = partion(sta,end);
115 | quick_sort(sta,q - 1);
116 | quick_sort(q + 1, end);
117 | }else{}
118 | }
119 |
120 | void reverse(int len){
121 | char temp;
122 | int i;
123 | i = +0;
124 | temp = str_test[i];
125 | str_test[i] = str_test[(len - i)];
126 | str_test[len - i] = temp;
127 | i = i + +1;
128 | while(i < (len / 2)){
129 | temp = str_test[i];
130 | str_test[i] = str_test[(len - i)];
131 | str_test[len - i] = temp;
132 | i = i + +1;
133 | }
134 | }
135 |
136 | int charCount{
137 | int sum,i;
138 | sum = 0;
139 | i = 0;
140 |
141 | switch(str_test[i]){
142 | case 'S':{
143 | if(str_test[i] == 'a')
144 | sum = sum + 1;
145 | else{}
146 | i = i + 1;
147 | while(i <= 10){
148 | if(str_test[i] == 'a')
149 | sum = sum + 1;
150 | else{}
151 | i = i + 1;
152 | }
153 | }
154 | case 'E':
155 | return (sum);
156 | }
157 |
158 | i = i + 1;
159 |
160 | while(1) {
161 | switch(str_test[i]){
162 | case 'S':{
163 | if(str_test[i] == 'a')
164 | sum = sum + 1;
165 | else{}
166 | i = i + 1;
167 | while(i <= 10){
168 | if(str_test[i] == 'a')
169 | sum = sum + 1;
170 | else{}
171 | i = i + 1;
172 | }
173 | }
174 | case 'E':
175 | return (sum);
176 | }
177 |
178 | i = i + 1;
179 | }
180 | }
181 |
182 | void other_test1{
183 | char score;
184 | printf(" !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
185 |
186 | printf("please input the mode before test(1~3)");
187 | scanf(score);
188 | switch(score){
189 | case '1':{
190 | printf("Easy");
191 | number[0] = 5;
192 | number[1] = 7;
193 | number[2] = 9;
194 | number[3] = 4;
195 | number[4] = 1;
196 | number[5] = 3;
197 | number[6] = 8;
198 | number[7] = 10;
199 | number[8] = 2;
200 | number[9] = 6;
201 | ans[0] = 1;
202 | ans[1] = 2;
203 | ans[2] = 3;
204 | ans[3] = 4;
205 | ans[4] = 5;
206 | ans[5] = 6;
207 | ans[6] = 7;
208 | ans[7] = 8;
209 | ans[8] = 9;
210 | ans[9] = 10;
211 | }
212 | case '2':{
213 | printf("Middle");
214 | ra = ra + 5;
215 | number[0] = 45;
216 | number[1] = 19;
217 | number[2] = 23;
218 | number[3] = 78;
219 | number[4] = 83;
220 | number[5] = 55;
221 | number[6] = 69;
222 | number[7] = 37;
223 | number[8] = 95;
224 | number[9] = 77;
225 | number[10] = 145;
226 | number[11] = 189;
227 | number[12] = 156;
228 | number[13] = 123;
229 | number[14] = 100;
230 | ans[0] = 19;
231 | ans[1] = 23;
232 | ans[2] = 37;
233 | ans[3] = 45;
234 | ans[4] = 55;
235 | ans[5] = 69;
236 | ans[6] = 77;
237 | ans[7] = 78;
238 | ans[8] = 83;
239 | ans[9] = 95;
240 | ans[10] = 100;
241 | ans[11] = 123;
242 | ans[12] = 145;
243 | ans[13] = 156;
244 | ans[14] = 189;
245 | }
246 | case '3':{
247 | printf("Hard");
248 | ra = ra + 10;
249 | number[0] = 120;
250 | number[1] = 854;
251 | number[2] = 165;
252 | number[3] = 785;
253 | number[4] = 666;
254 | number[5] = 475;
255 | number[6] = 324;
256 | number[7] = 218;
257 | number[8] = 165;
258 | number[9] = 994;
259 | number[10] = 1230;
260 | number[11] = 1542;
261 | number[12] = 1462;
262 | number[13] = 1864;
263 | number[14] = 1023;
264 | number[15] = 1000;
265 | number[16] = 1765;
266 | number[17] = 1952;
267 | number[18] = 1949;
268 | number[19] = 1764;
269 | ans[0] = 120;
270 | ans[1] = 165;
271 | ans[2] = 165;
272 | ans[3] = 218;
273 | ans[4] = 324;
274 | ans[5] = 475;
275 | ans[6] = 666;
276 | ans[7] = 785;
277 | ans[8] = 854;
278 | ans[9] = 994;
279 | ans[10] = 1000;
280 | ans[11] = 1023;
281 | ans[12] = 1230;
282 | ans[13] = 1462;
283 | ans[14] = 1542;
284 | ans[15] = 1764;
285 | ans[16] = 1765;
286 | ans[17] = 1864;
287 | ans[18] = 1949;
288 | ans[19] = 1952;
289 | }
290 | }
291 |
292 | }
293 |
294 | void other_test2{
295 | int i;
296 | int temp;
297 |
298 | str_test[0] = 'S';
299 | str_test[1] = 'a';
300 | str_test[2] = 'a';
301 | str_test[3] = 'a';
302 | str_test[4] = 'a';
303 | str_test[5] = 'a';
304 | str_test[6] = 'b';
305 | str_test[7] = 'b';
306 | str_test[8] = 'a';
307 | str_test[9] = 'b';
308 | str_test[10] = 'b';
309 | str_test[11] = 'E';
310 | str_test[12] = 'E';
311 |
312 | reverse(12);
313 |
314 | printf("The character a in str_test is encountered ",charCount);
315 |
316 | ra = 10;
317 | rb = 10;
318 | rc = 10;
319 | rd = 10;
320 | ss[0] = a + (-a);
321 | ra = (((ra + rb * rc + rd) / ((((rb * rc)) + (ra + rd)) + (88))) + (max(ra,rb))) - str_test[ss[0]] + 'H' + -70;
322 |
323 | ra = +ra + -10;
324 | while(ra >= 20){
325 | ra = +ra + -10;
326 | }
327 |
328 | if(ra < 20){
329 | ra = ++10 + 0;
330 | }else{}
331 | }
332 |
333 | void main(){
334 | int i;
335 | int sum,cov,aver;
336 |
337 | other_test2;
338 | other_test1;
339 |
340 |
341 | sum = calcu(ra);
342 | aver = sum / ra;
343 | cov = calcuCov(ra,aver);
344 | cov = cov / ra;
345 | printf("The sum of input numbers is ",sum);
346 | printf("The cov of input number is ",cov);
347 |
348 | quick_sort(0,ra-1);
349 |
350 | i = 0;
351 | if(number[i] != ans[i]){
352 | printf("quick sort failed!");
353 | return;
354 | }else{}
355 | i = i + 1;
356 | while(i < ra){
357 | if(number[i] != ans[i]){
358 | printf("quick sort failed!");
359 | return;
360 | }else{}
361 | i = i + 1;
362 | }
363 |
364 | printf("quick sort success!");
365 | fun_def_test;
366 | defi_test;
367 | return;
368 | }
--------------------------------------------------------------------------------
/测试文件/0/test_jjh.txt:
--------------------------------------------------------------------------------
1 | const int stepmask = -1;
2 | const char plus = '+', times = '*', minus = '-', div = '/',udl='_';
3 |
4 | int list[10];
5 | char op;
6 |
7 | int Fact(int n)
8 | {
9 | if (n == 0)
10 | return (+div*(minus / 1000 - 1) + plus - times--1 / times + ('/'*(-1 + 2)));
11 | else
12 | return (n*fact(n - 1));
13 | }
14 |
15 | int isLetter(char c1) {
16 | if (c1 == '_')
17 | return(1);
18 | else if (c1 >= 'a') {
19 | if (c1 <= 'z') {
20 | return(1);
21 | }
22 | else
23 | return(0);
24 | }
25 | else if (c1 >= 'A') {
26 | if (c1 <= 'Z') {
27 | return(1);
28 | }
29 | else;
30 | }
31 | else;
32 | return(0);
33 | }
34 |
35 | int choose_pivot(int i, int j)
36 | {
37 | return((i + j) / 2);
38 | }
39 |
40 | void printlist(int n)
41 | {
42 | int i;
43 | i = 0;
44 | while (i < n) {
45 | printf(" ", list[i]); i = i + 1;
46 | }
47 | }
48 |
49 | void quicksort(int m, int n)
50 | {
51 | int key, x, y, z, tmp;
52 |
53 | key = list[choose_pivot(m, n)];
54 | x = m;
55 | y = n;
56 | while (x <= y)
57 | {
58 | while (key list[x]) x = x + 1;
60 | if (x <= y) {
61 | tmp = list[x];
62 | list[x] = list[y];
63 | list[y] = tmp;
64 | x = x + 1;
65 | y = y - 1;
66 | }
67 | else;
68 | }
69 | if (x mid) j = j - 1;
67 | if (i <= j)
68 | {
69 | t = quickSortList[i];
70 | quickSortList[i] = quickSortList[j];
71 | quickSortList[j] = t;
72 | i = i + 1;
73 | j = j - 1;
74 | }
75 | else ;
76 | }
77 | if (l < j) quicksort(l, j); else;
78 | if (i < r) quicksort(i, r); else;
79 | }
80 |
81 | void bucketSort
82 | {
83 | int i;
84 | int j, cnt[20];
85 | j = 0;
86 | i = 0;
87 | while (i < 20)
88 | {
89 | cnt[i] = 0;
90 | i = i + 1;
91 | }
92 |
93 | i = 0;
94 | while (i < 10)
95 | {
96 | while (j <= bucketSortList[i])
97 | {
98 | cnt[j] = 0;
99 | j = j + 1;
100 | }
101 | cnt[bucketSortList[i]] = cnt[bucketSortList[i]] + 1;
102 |
103 | i = i + 1;
104 | }
105 |
106 | while (j > 0)
107 | {
108 | j = j - 1;
109 | while (cnt[j] > 0)
110 | {
111 | cnt[j] = cnt[j] - 1;
112 | i = i - 1;
113 | bucketSortList[i] = j;
114 | }
115 | }
116 | }
117 |
118 | int sortResultJudge
119 | {
120 | int i;
121 |
122 | i = 0;
123 | while (i < 10)
124 | {
125 | if (selectSortList[i] != i + two)
126 | return(1);
127 | else ;
128 |
129 | if (quickSortList[i] != i + two)
130 | return (2);
131 | else ;
132 |
133 | if (bucketSortList[i] != i + two)
134 | return (3);
135 | else;
136 | i = i + 1;
137 | }
138 |
139 | return (0);
140 | }
141 |
142 | void sortCheck
143 | {
144 | int result;
145 | sortInit;
146 | selectsort;
147 | quicksort(0, 9);
148 | bucketsort;
149 |
150 | result = sortResultJUdge;
151 | switch (result)
152 | {
153 | case 0: printf(" All Sort Algorithm Result Accepted!");
154 |
155 | case 1: printf(" Select Sort Failed!");
156 |
157 | case 2: printf(" Quick Sort Failed!");
158 |
159 | case 3: printf(" Bucket Sort Failed!");
160 |
161 | }
162 | }
163 |
164 | int Combinatorial(int m, int n)
165 | {
166 | if (m == n)
167 | return(1);
168 | else
169 | if (n == 0)
170 | return (1);
171 | else
172 | return (combinatorial(m-1, n) + Combinatorial(m-1, n-1) + two * 2 / ('c' - 'a') - 1);
173 | }
174 |
175 | void combinaCheck
176 | {
177 | int m, n;
178 | int res;
179 | scanf(m, n);
180 | res = combinatorial(m, n);
181 | printf(res);
182 | }
183 |
184 | void nextLetter(char ch)
185 | {
186 | const char la = 'a', lb = 'b', lc = 'c', ld = 'd', le = 'e',
187 | lf = 'f', lg = 'g', lh = 'h', li = 'i', lj = 'j',
188 | lk = 'k', ll = 'l', lm = 'm', ln = 'n', lo = 'o',
189 | lp = 'p', lq = 'q', lr = 'r', ls = 's', lt = 't',
190 | lu = 'u', lv = 'v', lw = 'w', lx = 'x', ly = 'y';
191 | const char LZ = 'z';
192 |
193 | char lower[26];
194 | int ind;
195 |
196 | lower[0] = la; lower[1] = lb; lower[2] = lc; lower[3] = ld; lower[4] = le;
197 | lower[5] = lf; lower[6] = lg; lower[7] = lh; lower[8] = li; lower[9] = lj;
198 | lower[10] = lk; lower[11] = ll; lower[12] = lm; lower[13] = ln; lower[14] = lo;
199 | lower[15] = lp; lower[16] = lq; lower[17] = lr; lower[18] = ls; lower[19] = lt;
200 | lower[20] = lu; lower[21] = lv; lower[22] = lw; lower[23] = lx; lower[24] = ly;
201 | lower[25] = lz;
202 |
203 | if (ch >= 'a')
204 | {
205 | if (ch <= 'z')
206 | {
207 | ind = ch - 'a' + 1;
208 | if (ind > 25)
209 | ind = 0;
210 | else ;
211 | printf(" Next letter: ", lower[ind]);
212 | }
213 | else
214 | printf(" Not a letter: ", ch);
215 | }
216 | else
217 | {
218 | if (ch >= 'A')
219 | {
220 | if (ch <= 'Z')
221 | {
222 | ind = ch - 'A' + 1;
223 | if (ind > 25)
224 | ind = 0;
225 | else ;
226 | printf(" Next letter: ", lower[ind]);
227 | }
228 | else
229 | printf(" Not a letter: ", ch);
230 | }
231 | else
232 | printf(" Not a letter: ", ch);
233 | }
234 |
235 |
236 | }
237 |
238 | void letterCheck
239 | {
240 | int n;
241 | char ch;
242 | scanf(n);
243 | while (n > 0)
244 | {
245 | scanf(ch);
246 | nextLetter(ch);
247 | n = n - 1;
248 | }
249 | }
250 |
251 | void main()
252 | {
253 | char _op;
254 | scanf(_op);
255 | switch(_op)
256 | {
257 | case 's': sortCheck;
258 | case 'c': combinaCheck;
259 | case 'n': letterCheck;
260 |
261 | default:
262 | printf("Error operation!");
263 | }
264 |
265 | }
--------------------------------------------------------------------------------
/测试文件/0/test_null.txt:
--------------------------------------------------------------------------------
1 | const INt _global_constInt = 7;
2 | cONst Char _message_to_the_world = '*';
3 |
4 | iNT _global_int_arr[10], _global_int;
5 | CHAR _global_char_arr[10], _global_char;
6 |
7 | inT fib(INt k)
8 | {
9 | if (k > 1)
10 | return (fib(k-1)+fib(k-2)+-1*0);
11 | else{}
12 | if (K == 0)
13 | {
14 | return (1);
15 | }else{}
16 | if (K == 1)
17 | {
18 | reTURN (1);
19 | }else{}
20 |
21 | }
22 |
23 | voiD if_TEST
24 | {
25 | if (1)
26 | {}else{}
27 | if (0)
28 | {;}else{}
29 | if (1);else{}
30 | if (fib(2))
31 | {
32 | if (fib(3) + 1)
33 | {
34 | prinTf("if test ok");
35 | }else{}
36 | }else{}
37 |
38 | }
39 |
40 | int loop_TEST(inT Loop_initVar, iNt loop_STEP, int loop_CNT)
41 | {
42 | iNT i, j;
43 | int Mark_cnt;
44 | i = loop_INITvar;
45 | Mark_cnt = loop_Cnt;
46 | J = I;
47 | I = i + loop_steP;
48 | loop_cnt = loop_CNt - 1;
49 | while (loop_cnt > 0)
50 | {
51 | I = i + loop_steP;
52 | loop_cnt = loop_CNt - 1;
53 | }
54 | j = j - 1;
55 | while (j > 0)
56 | j = j - 1;
57 |
58 |
59 | if (j == 0)
60 | {
61 | IF (I == LOOp_INItvar + loop_step * mark_CNT)
62 | {
63 | PrINTF("loop test ok");
64 | }else{}
65 | }else{}
66 |
67 |
68 | return (I);
69 | }
70 |
71 | chAR myToUpper(char InputChar)
72 | {
73 | if (inPUtchar == 'a')
74 | {
75 | return ('A');
76 | }else{}
77 | if (inputchar == 'b')
78 | return ('B');
79 | else{}
80 | if (inputCHAR == 'c')
81 | {
82 | RETURN ('C');
83 | }else{}
84 | IF (inputchar == 'd')
85 | {
86 | return ('D');
87 | }else{}
88 | if (INPUTCHAR == 'e')
89 | return ('E');
90 | else{}
91 | }
92 |
93 | vOId case_TEST
94 | {
95 | int TEST_num;
96 | chAr test_CHAR;
97 | prINtf("please input int(0-9) & char values(a-e):");
98 | scanF(test_NUM, TEST_char);
99 | switch (tEst_nUm)
100 | {
101 | CASE 0:
102 | prinTF(test_Num+TEst_char);
103 | case 1:
104 | {
105 | printf(test_num+TEST_CHAR);
106 | }
107 | case 2:
108 | printf(test_num+ test_char);
109 | case 3:
110 | {
111 | printf(TEST_num+test_CHAR) ;
112 | }
113 | CasE 4:
114 | printf(TEST_num+tEST_Char);
115 | case 5:
116 | {
117 | printf(test_NuM+Test_Char);
118 | }
119 | case 6:
120 | printf(tESt_NUM+TesT_ChaR);
121 | case 7:
122 | printf(test_num+test_char);
123 | case 8 :
124 | printf(test_NUM+TEst_char);
125 | case 9 :
126 | printf(TEST_NUM+TEST_CHAR);
127 | }
128 |
129 | switch (TEST_CHAR)
130 | {
131 | case 'a':
132 | {
133 | printf(mytoupper(test_CHAR));
134 | }
135 | case 'b':
136 | printf(MYTOUPPER(test_Char));
137 | case 'c':
138 | {
139 | printf(MytoUpper(TEST_CHAR));
140 | }
141 | case 'd':
142 | printf(mytoupper(test_char));
143 | case 'e':
144 | printf(mytoupper(TEST_CHAR));
145 | }
146 |
147 | }
148 |
149 | void setAverage
150 | {
151 | INT SUM, RET, i;
152 | sum = 0;
153 | i = 0;
154 | sum = sum + _global_char_arr[i];
155 | i = I+1;
156 | while(i < 10)
157 | {
158 | sum = sum + _global_char_arr[i];
159 | i = I+1;
160 | }
161 | ret = sum / 10;
162 | i = 0;
163 | _global_int = ret;
164 |
165 | }
166 |
167 | VoiD array_TEST
168 | {
169 | int i;
170 | I = 0;
171 |
172 | _GLObal_char_ARR[I] = 'a';
173 | I = I+1;
174 | WHILE (i < 10)
175 | {
176 | _GLObal_char_ARR[I] = 'a';
177 | I = I+1;
178 | }
179 |
180 | setAveragE;
181 | }
182 |
183 | void main()
184 | {
185 | int loop_initvar, loop_step, loop_cnt;
186 | if_test;
187 | printf("please input 3 int(the 3rd int must >0):");
188 | scanf(loop_initVAR, LOOP_STEP, LOOp_cnt);
189 | loop_initVAR = loop_test(LOOP_INITVAR, LOOP_STEP, LOOP_CNT);
190 | case_test;
191 | array_test;
192 | if (_global_INT == 97)
193 | {
194 | PRINTF("passed");
195 | }else{}
196 | }
--------------------------------------------------------------------------------
/测试文件/0/test_wyc.txt:
--------------------------------------------------------------------------------
1 | const int MAX_FACTOR = 10, MIN_FACTOR = 0;
2 | const char SUBSCRIPT = '_';
3 | int m, n;
4 | int result;
5 |
6 | int factorial(int f) {
7 | if (f <= 1) {
8 | return (1);
9 | } else {
10 | return (f * factorial(f-1));
11 | }
12 | }
13 |
14 | void display_error(int error_code) {
15 | switch (error_code) {
16 | case 1:
17 | printf("m is too big. ");
18 | case 2:
19 | printf("m is too small");
20 | case 3:
21 | printf("n is too big. ");
22 | case 4:
23 | printf("n is too small. ");
24 | case 5:
25 | printf("n should be no greater than m.");
26 | default:
27 | {
28 | printf("no errors seem found. ");
29 | }
30 | }
31 | }
32 |
33 | int expression_test {
34 | int this_is_1;
35 | this_is_1 = 1-(1-(1-(1-(1-(1-(1-(1-(1-(1-(1-(1-(1-(1-(1-(1-(1-(1-(1))))))))))))))))));
36 | return (this_is_1);
37 | }
38 |
39 | int for_factorial(int m) {
40 | int f;
41 | f = m;
42 | m = m - 1;
43 | while(m){
44 | f = f * m;
45 | m = m - 1;
46 | }
47 | return (f);
48 | }
49 |
50 | void main() {
51 | int error_code;
52 | int fact_m, fact_n, fact_m_sub_n;
53 |
54 | error_code = 0;
55 | scanf(m, n);
56 |
57 | if (expression_test != 1) {
58 | printf("Expression test failed! ");
59 | }else{}
60 |
61 | if (m > MAX_FACTOR) {
62 | error_code = 1;
63 | }else{}
64 | if (m < MIN_FACTOR) {
65 | error_code = 2;
66 | }else{}
67 | if (n > MAX_FACTOR) {
68 | error_code = 3;
69 | }else{}
70 | if (n < MIN_FACTOR) {
71 | error_code = 4;
72 | }else{}
73 | if (m - n < 0) {
74 | error_code = 5;
75 | }else{}
76 | display_error(error_code);
77 | if (error_code == 0) {
78 |
79 |
80 | fact_m = factorial(m);
81 |
82 | fact_n = factorial(n);
83 | fact_m_sub_n = factorial(m - n);
84 | printf("m! = ", fact_m);
85 | printf("repeat m! : ", for_factorial(m));
86 | printf("n! = ", fact_n);
87 | printf("repeat n! : ", for_factorial(n));
88 | printf("C(m, n) = ", fact_m / fact_n / fact_m_sub_n);
89 | }else{}
90 | }
--------------------------------------------------------------------------------
/测试文件/0/test_ycy.txt:
--------------------------------------------------------------------------------
1 | const int my_const1 = 10,my_const2 = -15;
2 | const char my_const3 = 'a',my_const4 = '9',my_const5 ='_';
3 |
4 | int my_var1,my_var2[15];
5 | char my_var3,my_var4[20];
6 |
7 | int my_function1(int function1_x){
8 | int a;
9 | a = 0;
10 |
11 | if(function1_x < 10){
12 | function1_x = function1_x*2;
13 | a = my_function1(function1_x);
14 | }
15 | else
16 | return (function1_x);
17 |
18 | return (a);
19 | }
20 |
21 | void my_function2(char function2_x,int function2_y){
22 | int i;
23 |
24 | my_var4[0]='H';
25 | my_var4[1]='E';
26 | my_var4[2]='L';
27 | my_var4[3]='L';
28 | my_var4[4]='O';
29 | my_var4[5]='W';
30 |
31 | my_var4[6]='W';
32 | my_var4[7]='O';
33 | my_var4[8]='R';
34 | my_var4[9]='L';
35 | my_var4[10]='D';
36 |
37 | i = 0;
38 | while(i<11){
39 | if(i == function2_y)
40 | my_var4[i]=function2_x;
41 | else{}
42 | i = i + 1;
43 | }
44 | return;
45 |
46 | }
47 |
48 | void main(){
49 | int op;
50 | int function1_arg1,function2_arg1;
51 | char function2_arg2;
52 | int function_return;
53 | int i;
54 |
55 | printf("INPUT YOUR OPCODE,0 : function1_x , 1: function2");
56 | scanf(op);
57 |
58 | switch(op){
59 | case 0:{
60 | printf("input a num");
61 | scanf(function1_arg1);
62 | function_return=my_function1(function1_arg1);
63 | printf("return code is ",function_return );
64 | }
65 |
66 | case 1:{
67 | printf("input a char ");
68 | scanf(function2_arg2);
69 | printf(" input a num (num < 11) ");
70 | scanf(function2_arg1);
71 | my_function2(function2_arg2,function2_arg1);
72 | i = 0;
73 | while(i < 11){
74 | printf(my_var4[i]);
75 | i = i + 1;
76 | }
77 | }
78 | default:
79 | printf("error op!",op);
80 | }
81 |
82 | return;
83 |
84 | }
--------------------------------------------------------------------------------
/测试文件/0/test_yww.txt:
--------------------------------------------------------------------------------
1 | const int maxsize = 100;
2 | const int MAXNUM = 100000;
3 | const int MINNUM = -100000;
4 | int array[100];
5 | int O_left, O_right,O_sum;
6 | void find_max_crossing_subarray(int left_index, int right_index)
7 | {
8 | int left_sum,right_sum,sum,mid,i;
9 | mid = (left_index + right_index) / 2;
10 | left_sum = MINNUM;
11 | sum = 0;
12 | i = mid;
13 | sum = sum + array[i];
14 | if (sum > left_sum)
15 | {
16 | left_sum = sum;
17 | O_left = i;
18 | }else{}
19 | i = i - 1;
20 | while (i >= left_index) {
21 | sum = sum + array[i];
22 | if (sum > left_sum)
23 | {
24 | left_sum = sum;
25 | O_left = i;
26 | }else{}
27 | i = i - 1;
28 | }
29 | right_sum = MINNUM;
30 | sum = 0;
31 | i = mid+1;
32 | sum = sum + array[i];
33 | if (sum > right_sum)
34 | {
35 | right_sum = sum;
36 | O_right = i;
37 | }else{}
38 | i = i + 1;
39 | while (i <=right_index) {
40 | sum = sum + array[i];
41 | if (sum > right_sum)
42 | {
43 | right_sum = sum;
44 | O_right = i;
45 | }else{}
46 | i = i + 1;
47 | }
48 | O_sum = left_sum + right_sum;
49 | return;
50 | }
51 | int find_maximum_subarray(int left_index, int right_index)
52 | {
53 | int mid,sum;
54 | int ll, lr, rl, rr, crossingl, crossingr,lsum, rsum, crossingsum;
55 | char tag;
56 | if (left_index == right_index)
57 | {
58 | O_left = left_index;
59 | O_right = right_index;
60 | return (array[left_index]);
61 | }else{}
62 | mid = (left_index + right_index) / 2;
63 | lsum=find_maximum_subarray(left_index, mid);
64 | ll = O_left;
65 | lr = O_right;
66 | rsum=find_maximum_subarray(mid + 1, right_index);
67 | rl = O_left;
68 | rr = O_right;
69 | find_max_crossing_subarray(left_index, right_index);
70 | crossingsum = O_sum;
71 | crossingl = O_left;
72 | crossingr = O_right;
73 |
74 | tag = 'l';
75 | sum = lsum;
76 | if (rsum > sum)
77 | {
78 | sum = rsum;
79 | tag = 'r';
80 | }else{}
81 | if (crossingsum > sum)
82 | {
83 | sum = crossingsum;
84 | tag = 'm';
85 | }else{}
86 | switch (tag)
87 | {
88 | case 'l': {
89 | O_left = ll;
90 | O_right = lr;
91 | return (sum);
92 | }
93 | case'm': {
94 | O_left = crossingl;
95 | O_right = crossingr;
96 | return (sum);
97 | }
98 | case'r': {
99 | O_left = rl;
100 | O_right = rr;
101 | return (sum);
102 | }
103 | }
104 | }
105 | void test1
106 | {
107 | int arraysize,i,subarraysum_max;
108 | i=0;
109 | array[i]=13;
110 | i=i+1;
111 | array[i]=-3;
112 | i=i+1;
113 | array[i]=-25;
114 | i=i+1;
115 | array[i]=20;
116 | i=i+1;
117 | array[i]=-3;
118 | i=i+1;
119 | array[i]=-16;
120 | i=i+1;
121 | array[i]=-23;
122 | i=i+1;
123 | array[i]=18;
124 | i=i+1;
125 | array[i]=20;
126 | i=i+1;
127 | array[i]=-7;
128 | i=i+1;
129 | array[i]=12;
130 | i=i+1;
131 | array[i]=-5;
132 | i=i+1;
133 | array[i]=-22;
134 | i=i+1;
135 | array[i]=15;
136 | i=i+1;
137 | array[i]=-4;
138 | i=i+1;
139 | array[i]=7;
140 | i=i+1;
141 | subarraysum_max=find_maximum_subarray(0, i - 1);
142 | printf("Test 1:");
143 | printf("left_index=", O_left);
144 | printf("right_index=", O_right);
145 | printf("Subarray sum=", subarraysum_max);
146 | if(subarraysum_max==43)
147 | {
148 | if(O_left==7)
149 | {
150 | if(10==O_right)
151 | {
152 | printf("Test 1 passed!");
153 | return ;
154 | }else{}
155 | }else{}
156 | }else{}
157 | printf("Test 1 failed!");
158 | return ;
159 | }
160 | void test2
161 | {
162 | int arraysize,i,subarraysum_max;
163 | i=0;
164 | array[i]=3;
165 | i=i+1;
166 | array[i]=5;
167 | i=i+1;
168 | array[i]=-2;
169 | i=i+1;
170 | array[i]=-6;
171 | i=i+1;
172 | array[i]=-5;
173 | i=i+1;
174 | array[i]=8;
175 | i=i+1;
176 | array[i]=12;
177 | i=i+1;
178 | array[i]=-5;
179 | i=i+1;
180 | array[i]=-6;
181 | i=i+1;
182 | array[i]=24;
183 | i=i+1;
184 | array[i]=8;
185 | i=i+1;
186 | array[i]=6;
187 | i=i+1;
188 | array[i]=-8;
189 | i=i+1;
190 | array[i]=-7;
191 | i=i+1;
192 | subarraysum_max=find_maximum_subarray(0, i - 1);
193 | printf("Test 2:");
194 | printf("left_index=", O_left);
195 | printf("right_index=", O_right);
196 | printf("Subarray sum=", subarraysum_max);
197 | if(subarraysum_max==47)
198 | {
199 | if(O_left==5)
200 | {
201 | if(11==O_right)
202 | {
203 | printf("Test 2 passed!");
204 | return;
205 | }else{}
206 | } else{}
207 | }else{}
208 | printf("Test 2 failed!");
209 | return;
210 | }
211 | void test3
212 | {
213 | int arraysize,i,subarraysum_max;
214 | i=0;
215 | array[i]=1;
216 | i=i+1;
217 | array[i]=-1;
218 | i=i+1;
219 | array[i]=2;
220 | i=i+1;
221 | array[i]=-2;
222 | i=i+1;
223 | array[i]=3;
224 | i=i+1;
225 | array[i]=-3;
226 | i=i+1;
227 | array[i]=4;
228 | i=i+1;
229 | array[i]=-4;
230 | i=i+1;
231 | array[i]=5;
232 | i=i+1;
233 | array[i]=-5;
234 | i=i+1;
235 | subarraysum_max=find_maximum_subarray(0, i - 1);
236 | printf("Test 3:");
237 | printf("left_index=", O_left);
238 | printf("right_index=", O_right);
239 | printf("Subarray sum=", subarraysum_max);
240 | if(subarraysum_max==5)
241 | {
242 | if(O_left==8)
243 | {
244 | if(8==O_right)
245 | {
246 | printf("Test 3 passed!");
247 | return;
248 | }else{}
249 | } else{}
250 | }else{}
251 | printf("Test 3 failed!");
252 | return;
253 | }
254 |
255 | void main()
256 | {
257 | char Tag;
258 | printf("Please input your choice number:(<0>quit <1>Test 1 <2>Test 2 <3>Test 3)");
259 | scanf(Tag);
260 | switch(Tag)
261 | {
262 | case '0':
263 | ;
264 | case '1':
265 | test1;
266 | case '2':
267 | test2;
268 | case '3':
269 | test3;
270 | }
271 | printf("Quit Test...");
272 | return;
273 | }
--------------------------------------------------------------------------------
/测试文件/0/test_zf.txt:
--------------------------------------------------------------------------------
1 | const int MAX=10;
2 | const cHaR A='a';
3 | const cHaR plus = '+', minus = '-', mult = '*', div = '/';
4 |
5 | int n,x,y,kind,m,ans,_a,_b;
6 | char ch,alphabet[26];
7 |
8 | Void testDefine
9 | {
10 | CONST int int0=0,int1=1,int10=10;
11 |
12 | const int int_0=0,int_1=-1,int_10=-10;
13 |
14 | const int _int0=0,_int1=+1,_int10=+10;
15 |
16 | const char char0='0',char1='1';
17 |
18 | int var0,var1,arr1[1],var11,arr11[11];
19 |
20 | alphabet[0] = 'a';
21 | alphabet[1] = 'b';
22 | alphabet[2] = 'c';
23 | alphabet[3] = 'd';
24 | alphabet[4] = 'e';
25 | alphabet[5] = 'f';
26 | alphabet[6] = 'g';
27 | alphabet[7] = 'h';
28 | alphabet[8] = 'i';
29 | alphabet[9] = 'j';
30 | alphabet[10] = 'k';
31 | alphabet[11] = 'l';
32 | alphabet[12] = 'm';
33 | alphabet[13] = 'n';
34 | alphabet[14] = 'o';
35 | alphabet[15] = 'p';
36 | alphabet[16] = 'q';
37 | alphabet[17] = 'r';
38 | alphabet[18] = 's';
39 | alphabet[19] = 't';
40 | alphabet[20] = 'u';
41 | alphabet[21] = 'v';
42 | alphabet[22] = 'w';
43 | alphabet[23] = 'x';
44 | alphabet[24] = 'y';
45 | alphabet[25] = 'z';
46 | }
47 |
48 | int fibo(int n)
49 | {
50 | if (n<0) return(-1);
51 | else if (n==0) return(0);
52 | else if (n==1) return(1);
53 | else if (n>MAX) return(-2);
54 | else return(fibo(n-1)+fibo(n-2));
55 | }
56 |
57 | void printspace
58 | {
59 | printf(" ");
60 | }
61 |
62 | void display(int m)
63 | {
64 | int i;
65 | char letter;
66 | if (m<=0)
67 | return;
68 | else if (m>26)
69 | m = 26;
70 | else {
71 | i = 0;
72 | while(i?@[\]^_`{|}~");
133 | }
134 | {
135 | ;
136 | }
137 | ;
138 | {}
139 | }
140 |
141 | void main()
142 | {
143 | int i,num;
144 | i = 0;
145 | testDefine;
146 | scanf(num);
147 | while (ibb)
14 | {
15 | switch(cc-'i')
16 | {
17 | case 0:return (a*_aSfunc_1(aa-bb,'i'));
18 | default:{return (a*_aSfunc_1(aa-1,'c'));}
19 | }
20 | }
21 | else
22 | {
23 | switch(cc)
24 | {
25 | case 'i':printf("The result of case i is done!");
26 | default:printf("The result of case c is done!");
27 | }
28 | return (1);
29 | }
30 | }
31 | int min(int a,int b)
32 | {
33 | if(a < b)
34 | {
35 | return (a);
36 | }
37 | else
38 | {
39 | if(a == b)
40 | {
41 | return (a);
42 | }
43 | else
44 | {
45 | return (b);
46 | }
47 | }
48 | }
49 | int max(int a,int b)
50 | {
51 | if(a > b)
52 | {
53 | return (a);
54 | }
55 | else
56 | {
57 | return (b);
58 | }
59 | }
60 |
61 | void no_Sfc(int a,int b)
62 | {
63 | int aa,bb;
64 | aa=a;
65 | bb=b;
66 | if(aa > maxs)
67 | {
68 | res = -1;
69 | return;
70 | }
71 | else
72 | {
73 | ;
74 | }
75 | begin = min(aa,bb);
76 | end = max(aa,bb);
77 | res = (begin + end)*(end - begin +1)/2;
78 | }
79 | void print1(int res1,int res2)
80 | {
81 | printf("result one is:");
82 | printf(res1);
83 | printf("result two is:",+res2+2-1-1);
84 | }
85 | void print2
86 | {
87 | if(res != -1)
88 | {
89 | printf("The sum of numbers between two results is:",res);
90 | }
91 | else
92 | {
93 | printf("no result!");
94 | }
95 | }
96 | void main()
97 | {
98 | const int first=1,second=2;
99 | const char p1='+',p2='-',p3='*',p4='/';
100 | int s_firi,s_seci,ni,nc,resultI,resultC,i,j,k,flag;
101 | char s_firc,s_secc,p_fir,p_sec;
102 | scanf(s_firi,s_seci,s_firc,s_secc);
103 | if(s_firi < 0)
104 | {
105 | printf("wrong input!");
106 | return;
107 | }
108 | else
109 | {
110 | if(s_seci < 0)
111 | {
112 | printf("wrong input!");
113 | return;
114 | }
115 | else
116 | {
117 | ;
118 | }
119 | }
120 | if(s_firi >= s_seci)
121 | {
122 | ni = s_firi;
123 | }
124 | else
125 | {
126 | ni = s_seci;
127 | }
128 | if(ni <= 0)
129 | {
130 | while(ni <= +0)
131 | {
132 | ni = ni + 1;
133 | }
134 | }
135 | else
136 | {
137 | ni = ni + 1;
138 | }
139 | switch( +s_firc - s_secc )
140 | {
141 | case 1:nc = 1;
142 | case 2:nc = 2;
143 | case -1:nc = 3;
144 | case -2:nc = 4;
145 | default:nc = 5;
146 |
147 | }
148 | resultI = _aSfunc_1(ni,'i');
149 | resultC = _aSfunc_1(nc,'c');
150 | print1(resultI,resultC);
151 | no_Sfc(resultI,resultC);
152 | print2;
153 | return;
154 | }
--------------------------------------------------------------------------------
/测试文件/15061129_test.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/15061129_test.txt
--------------------------------------------------------------------------------
/测试文件/error0.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/error0.txt
--------------------------------------------------------------------------------
/测试文件/error1.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/error1.txt
--------------------------------------------------------------------------------
/测试文件/error2.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/error2.txt
--------------------------------------------------------------------------------
/测试文件/error3.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/error3.txt
--------------------------------------------------------------------------------
/测试文件/error4.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/error4.txt
--------------------------------------------------------------------------------
/测试文件/error5.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xxr5566833/Compiler/dd36b29e7313550702012d8390688e49c9783d9d/测试文件/error5.txt
--------------------------------------------------------------------------------