Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
2
2022fall-Compiler_CMinus
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李晓奇
2022fall-Compiler_CMinus
Commits
78a60f29
Commit
78a60f29
authored
Feb 04, 2023
by
lxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add 2 cases
parent
7e736683
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
128 additions
and
0 deletions
+128
-0
tests/5-bonus/testcases/14-const-prop.cminus
tests/5-bonus/testcases/14-const-prop.cminus
+23
-0
tests/5-bonus/testcases/14-const-prop.in
tests/5-bonus/testcases/14-const-prop.in
+1
-0
tests/5-bonus/testcases/14-const-prop.out
tests/5-bonus/testcases/14-const-prop.out
+1
-0
tests/5-bonus/testcases/15-transpose.cminus
tests/5-bonus/testcases/15-transpose.cminus
+70
-0
tests/5-bonus/testcases/15-transpose.in
tests/5-bonus/testcases/15-transpose.in
+32
-0
tests/5-bonus/testcases/15-transpose.out
tests/5-bonus/testcases/15-transpose.out
+1
-0
No files found.
tests/5-bonus/testcases/14-const-prop.cminus
0 → 100644
View file @
78a60f29
void main(void) {
int c;
int a;
int b;
int d;
int f;
int g;
int loopCnt;
loopCnt = input();
c = 0;
a = 0;
g = 0;
while (c < loopCnt) {
a = 1.23456 * 5.73478 * 2.3333 * 4.3673 * 6.34636;
b = a * a * a * a * a * a;
d = b * b * b * b * b * b;
f = d * d * d * d * d * d;
g = f * f * f * f * f * f;
c = c + 1;
}
output(g);
return;
}
\ No newline at end of file
tests/5-bonus/testcases/14-const-prop.in
0 → 100644
View file @
78a60f29
100000000
tests/5-bonus/testcases/14-const-prop.out
0 → 100644
View file @
78a60f29
711082625
tests/5-bonus/testcases/15-transpose.cminus
0 → 100644
View file @
78a60f29
int matrix[20000000];
int ad[100000];
int len;
void readarray(void) {
int cnt;
cnt = 0;
while (cnt < len) {
ad[cnt] = input();
cnt = cnt + 1;
}
}
int transpose(int n, int matrix[], int rowsize) {
int colsize;
int i;
int j;
int curr;
colsize = n / rowsize;
i = 0;
j = 0;
while (i < colsize) {
j = 0;
while (j < rowsize) {
if (i < j) {
j = j + 1;
} else {
curr = matrix[i * rowsize + j];
matrix[j * colsize + i] = matrix[i * rowsize + j];
matrix[i * rowsize + j] = curr;
j = j + 1;
}
}
i = i + 1;
}
return 0 - 1;
}
int main(void) {
int n;
int i;
int ans;
n = input();
len = input();
readarray();
i = 0;
while (i < n) {
matrix[i] = i;
i = i + 1;
}
i = 0;
while (i < len) {
transpose(n, matrix, ad[i]);
i = i + 1;
}
ans = 0;
i = 0;
while (i < len) {
ans = ans + i * i * matrix[i];
i = i + 1;
}
if (ans < 0) {
ans = 0 - ans;
}
output(ans);
return 0;
}
tests/5-bonus/testcases/15-transpose.in
0 → 100644
View file @
78a60f29
10000000
30
2
5
4
25
8
125
16
625
32
3125
2
5
4
25
8
125
16
625
32
3125
2
5
4
25
8
125
16
625
32
3125
tests/5-bonus/testcases/15-transpose.out
0 → 100644
View file @
78a60f29
1042523985
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment