source: CIVL/examples/arithmetic/mean.cvl@ 85d4675

1.23 2.0 main test-branch
Last change on this file since 85d4675 was 89b55f5, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

Cleaned up arithmetic examples/tests

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

  • Property mode set to 100644
File size: 503 bytes
Line 
1/* Commandline execution:
2 * civl verify -inputB=10 mean.cvl
3 */
4$input int B;
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.