summaryrefslogtreecommitdiff
path: root/37/CH7/EX7.2/s2.sci
diff options
context:
space:
mode:
Diffstat (limited to '37/CH7/EX7.2/s2.sci')
-rwxr-xr-x37/CH7/EX7.2/s2.sci41
1 files changed, 16 insertions, 25 deletions
diff --git a/37/CH7/EX7.2/s2.sci b/37/CH7/EX7.2/s2.sci
index a8638db30..3406b80cf 100755
--- a/37/CH7/EX7.2/s2.sci
+++ b/37/CH7/EX7.2/s2.sci
@@ -1,25 +1,16 @@
-function[]=sortedsearch(a,n,ele)
- if(a(1)>ele|a(n)<ele)
- disp("NOT IN THE LIST");
- else
- i=1;
- j=0;
- for i=1:n
- if(a(i)==ele)
- printf("FOUND %d AT %d",ele,i);
- j=1;
- else
- if(a(i)>ele)
- break;
- end
- end
- end
- if(j==0)
- disp("%d NOT FOUND",ele);
- end
- end
-endfunction
-//Calling Routine:
-a=[2 22 23 33 121 222 233]//a should be sorted
-disp(a,"Given array");
-search(a,7,23)
+function[]=sortedsearch(a,n,ele)
+ if(a(1)&gt;ele|a(n)<ele) disp("not="" in="" the="" list");="" else="" i="1;" j="0;" for="" if(a(i)="=ele)" printf("found="" %d="" at="" %d",ele,i);="">ele)
+ break;
+ end
+ end
+ end
+ if(j==0)
+ disp("%d NOT FOUND",ele);
+ end
+ end
+endfunction
+//Calling Routine:
+a=[2 22 23 33 121 222 233]//a should be sorted
+disp(a,"Given array");
+sortedsearch(a,7,23)
+</ele)> \ No newline at end of file