source: CIVL/examples/languageFeatures/quantifiedComp.cvl@ b7a3ce6

1.23 2.0 main test-branch
Last change on this file since b7a3ce6 was 9f6d294, checked in by Yihao Yan <yihaoyan1@…>, 10 years ago

minor changes

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

  • Property mode set to 100644
File size: 589 bytes
Line 
1/*
2This is a verifyThis problem in 2012.
3This task asks you to get the longest common prefix of
4two subStrings.
5
6Input: an integer array arr, the length of the array, and two indices x and y.
7*/
8
9#include <civlc.cvh>
10#include <assert.h>
11
12$input int n=3;
13$input int x;
14$input int y;
15$input int X1[n];
16
17$assume (x < n && y < n && x >=0 && y>=0);
18
19int lcp(int *arr, int n, int x, int y){
20 int l=0;
21 while (x+l<n && y+l<n && arr[x+l]==arr[y+l]) {
22 l++;
23 }
24 return l;
25}
26
27void main(){
28 int result = lcp(X1, n, x, y);
29 assert($forall {int i | i>=0 && i<result} X1[x+i] == X1[y+i]);
30}
Note: See TracBrowser for help on using the repository browser.