Lee_assign22 - cout<< a[j]<< " "...

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 #include<iostream> #include<cmath> using namespace std int main() { int choice=0 while(choice != 4){ cout<< "What would you like to do? Select 1, 2, 3 or 4" <<endl cout<< "+------------------------------------------------------+" <<endl cout<< "| 1. Replace smallest integer with 100 |" <<endl cout<< "| 2. Array in Ascending order |" <<endl cout<< "| 3. Shift values one place to the right |" <<endl cout<< "| 4. Exit |" <<endl cout<< "+------------------------------------------------------+" <<endl cin>>choice cout<< endl switch (choice){ case 1: { double a[8]={-1, 2, 0, -5, 7, 4, 1, 7} double min=a[0] int x=0 for(int i=0 i<8 i++){ if(a[i]<min){ min=a[i] m x=i } } min=100 a[x]=min for(int j=0 j<8 j++)
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<< a[j]<< " " cout<< endl break } case 2: { double a[8]={-1, 2, 0, -5, 7, 4, 1, 7} double min=a[0] int x=0 for(int i=0 i<8 i++){ if(a[i]<min){ min=a[i] x=i } } double t=a[x+1] for(int j=x j>0 j--) a[j+1]=a[j] a[x+1]=t a[1]=a[0] Sheet1 Page 2 a[0]=min for(int k=0 k<8 k++) cout<<a[k]<<" " cout<<endl break } case 3: { double a[8]={-1, 2, 0, -5, 7, 4, 1, 7} double t=a[0] for(int i=8 i>0 i--) a[i+1]=a[i] a[1]=t for(int j=0 j<8 j++) cout<<a[j]<<" " cout<<endl break } case 4: { cout<< "You have chosen to exit." <<endl cout<< endl break } default: { cout<< "You have entered an invalid input." <<endl cout<< "Please try again." <<endl } } } return 0 }...
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_assign22 - cout<< a[j]<< " "...

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