source: CIVL/examples/arithmetic/assoc.cvl@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 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: 586 bytes
RevLine 
[06b8536c]1/* assoc.cvl: adds the elements of an array in two different
2 * orders, and checks the results agree. This relies on the
3 * use of real arithmetic, as opposed to floating-point
4 * arithmetic.
5 *
6 * Should be run at commandline specifying an upper bound on
7 * the length of the array. Example:
8 * civl verify -inputB=100 assoc.cvl
9 */
[9803bc1]10#include <civlc.cvh>
[0baeebd]11$input int B = 10;
[06b8536c]12$input int n;
[f3282f0]13$assume(0<n && n<B);
[793cfc2]14$input double a[n];
15
16void main() {
17 double s0 = 0.0;
18 double s1 = 0.0;
[06b8536c]19
[793cfc2]20 for (int i = 0; i < n; i++) {
21 s0 += a[i];
22 s1 += a[n-1-i];
23 }
[d980649]24 $assert(s0 == s1);
[793cfc2]25}
Note: See TracBrowser for help on using the repository browser.