source: CIVL/examples/arithmetic/mean.cvl

main
Last change on this file was b689afd, checked in by Stephen Siegel <siegel@…>, 4 weeks ago

Getting rid of unused examples that are not good and starting to clean
up others.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@6036 fb995dde-84ed-4084-dfe6-e5aef3e2452c

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