source: CIVL/examples/arithmetic/meanBad.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: 609 bytes
RevLine 
[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 */
[0baeebd]6$input int B = 10;
[b96205d]7$input int n;
[3ff27cf]8$assume(1<=n && n<=B);
[b96205d]9$input double a[n];
10double s;
11
12void main() {
13 double mean1() {
14 double sum=0.0;
15
16 for (int i=0; i<n; i++)
17 sum += a[i];
18 return sum/n;
19 }
20 double mean2() {
21 double result=a[0];
22
23 for (int i=1; i<n; i++)
24 result = result*(i/(i+1)) + a[i]/(i+1);
25 return result;
26 }
27 double result1 = mean1();
28 double result2 = mean2();
[d980649]29 $assert(result1==result2);
[b96205d]30}
Note: See TracBrowser for help on using the repository browser.