1.23
2.0
main
test-branch
|
Last change
on this file since 38b7d06 was ee41939, checked in by Stephen Siegel <siegel@…>, 13 years ago |
|
Implemented sizeof (but need tests), corrected error in dynamicStruct.cvl example (sum is n*(n-1)/2, not n*(n+1)/2), other minor improvements.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@168 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
334 bytes
|
| Line | |
|---|
| 1 | #include <civlc.h>
|
|---|
| 2 |
|
|---|
| 3 | void f(int n) {
|
|---|
| 4 | int sum;
|
|---|
| 5 | typedef struct foo {
|
|---|
| 6 | int sum;
|
|---|
| 7 | int bar[n];
|
|---|
| 8 | } foo;
|
|---|
| 9 |
|
|---|
| 10 | foo s;
|
|---|
| 11 | sum = (n * (n - 1)) / 2;
|
|---|
| 12 | if (n > 1) {
|
|---|
| 13 | $spawn f(n-1);
|
|---|
| 14 | }
|
|---|
| 15 | s.sum = 0;
|
|---|
| 16 | for (int i = 0; i < n; i++) {
|
|---|
| 17 | s.bar[i] = i;
|
|---|
| 18 | s.sum += s.bar[i];
|
|---|
| 19 | }
|
|---|
| 20 | $assert sum == s.sum;
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | void main() {
|
|---|
| 24 | $spawn f(3);
|
|---|
| 25 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.