Lee_assig24a - cout<<endl return 0 }...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 //Cheu Lee Assign 24 #include<iostream> using namespace std int mySearch(int array[], int key, int length) void mySort(int array[],int length) int main() { int myArray[8]={1,3,-1,0,5,7,2,11} int myNumber,index cout<<"Enter a number that you want to search:\n" cin>>myNumber index=mySearch(myArray,myNumber,8) if(index==-1) cout<<"Not found!\n" else cout<<"The number is found: in the element "<<index<<endl mySort(myArray,8) for(int i=0 i<8 i++) cout<<myArray[i]<<" "
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout&lt;&lt;endl return 0 } int mySearch(int array, int key, int length) { int found = -1 for(int i=0 i&lt;length i++) { if(array[i]==key) found = i+1 } return found } void mySort(int array,int length) { int h for(int i=0 i&lt;length i++) { for(int j=0 j&lt;length-1 j++) { if(array[j]&gt;array[j+1]) { h=array[j] array[j]=array[j+1] array[j+1]=h } } Sheet1 Page 2 } for(int i=0 i&lt;length i++) cout&lt;&lt;array[i]&lt;&lt;&quot; &quot; }...
View Full Document

This note was uploaded on 05/16/2010 for the course CISCO EST61 taught by Professor Miller during the Spring '10 term at Fresno City College.

Page1 / 2

Lee_assig24a - cout&amp;amp;lt;&amp;amp;lt;endl return 0 }...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online