source: CIVL/examples/arithmetic/mean.cvl@ bb03188

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: 530 bytes
Line 
1/* Commandline execution:
2 * civl verify -inputB=10 mean.cvl
3 */
4#include<civlc.cvh>
5$input int B = 10;
6$input int n;
7$assume(1<=n && n<=B);
8$input double a[n];
9double s;
10
11void main() {
12 double mean1() {
13 double sum=0.0;
14
15 for (int i=0; i<n; i++)
16 sum += a[i];
17 return sum/n;
18 }
19 double mean2() {
20 double result=a[0];
21
22 for (int i=1; i<n; i++)
23 result = result*(i*1.0/(i+1)) + a[i]/(i+1);
24 return result;
25 }
26 double result1 = mean1();
27 double result2 = mean2();
28 $assert(result1==result2);
29}
Note: See TracBrowser for help on using the repository browser.