main
test-branch
|
Last change
on this file since bb03188 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
629 bytes
|
| Rev | Line | |
|---|
| [89b55f5] | 1 | /* Commandline execution:
|
|---|
| [9fb69d3] | 2 | * civl verify -inputB=10 meanBad.cvl
|
|---|
| 3 | * or (if you want to find the minimal counterexample)
|
|---|
| [89b55f5] | 4 | * civl verify -inputB=10 -min meanBad.cvl
|
|---|
| 5 | */
|
|---|
| [9803bc1] | 6 | #include<civlc.cvh>
|
|---|
| [0baeebd] | 7 | $input int B = 10;
|
|---|
| [b96205d] | 8 | $input int n;
|
|---|
| [3ff27cf] | 9 | $assume(1<=n && n<=B);
|
|---|
| [b96205d] | 10 | $input double a[n];
|
|---|
| 11 | double s;
|
|---|
| 12 |
|
|---|
| 13 | void main() {
|
|---|
| 14 | double mean1() {
|
|---|
| 15 | double sum=0.0;
|
|---|
| 16 |
|
|---|
| 17 | for (int i=0; i<n; i++)
|
|---|
| 18 | sum += a[i];
|
|---|
| 19 | return sum/n;
|
|---|
| 20 | }
|
|---|
| 21 | double mean2() {
|
|---|
| 22 | double result=a[0];
|
|---|
| 23 |
|
|---|
| 24 | for (int i=1; i<n; i++)
|
|---|
| 25 | result = result*(i/(i+1)) + a[i]/(i+1);
|
|---|
| 26 | return result;
|
|---|
| 27 | }
|
|---|
| 28 | double result1 = mean1();
|
|---|
| 29 | double result2 = mean2();
|
|---|
| [d980649] | 30 | $assert(result1==result2);
|
|---|
| [b96205d] | 31 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.