main
| Rev | Line | |
|---|
| [aad342c] | 1 | #include<stdio.h>
|
|---|
| 2 |
|
|---|
| 3 | // CIVL has a predefined macro _CIVL
|
|---|
| 4 | #ifdef _CIVL
|
|---|
| 5 | // CIVL will make N an input variable
|
|---|
| 6 | // automatically
|
|---|
| 7 | #include <civlc.cvh>
|
|---|
| 8 | $input int N;
|
|---|
| 9 | $assume(0 < N && N < 10);
|
|---|
| 10 | #else
|
|---|
| 11 | // if not runned by CIVL,
|
|---|
| 12 | // then make N a macro.
|
|---|
| 13 | #define N 100
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | int input[N];
|
|---|
| 17 | int sum = 0;
|
|---|
| 18 |
|
|---|
| 19 | int main(){
|
|---|
| 20 | for(int i = 0; i < N; i++)
|
|---|
| 21 | input[i] = i;
|
|---|
| 22 | for(int i = 0; i < N; i++)
|
|---|
| 23 | sum += input[i];
|
|---|
| 24 | #ifdef _CIVL
|
|---|
| 25 | // assertion only added for CIVL
|
|---|
| 26 | $assert(sum == N*(N-1)/2);
|
|---|
| 27 | #endif
|
|---|
| 28 | printf("N = %d, sum = %d\n", N, sum);
|
|---|
| 29 | fflush(stdout);
|
|---|
| 30 | return 0;
|
|---|
| 31 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.