Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- string names[13]{"Ageloff","Anderson","Biegel","Biow","Bisland","Arnott","Arnston","Ault","Avison","Bard","Bowman","Adams","Adrian"};
- for(int c=0;c<13;c++)cout<<names[c]<<", ";
- string alist="", blist="", temp="";
- for(int c=0;c<13;c++)
- {
- temp=names[c];
- if(temp[0]=='A')
- {
- alist+=temp;
- alist+=", ";
- }
- }
- cout<<"\nNames beginning with A: "<<alist;
- for(int c=0;c<13;c++)
- {
- temp=names[c];
- if(temp[0]=='B')
- {
- blist+=temp;
- blist+=", ";
- }
- }
- cout<<"\nNames beginning with B: "<<blist<<endl;
- string nameSearch;
- cout<<"Enter a name to be searched for: ";
- cin>>nameSearch;
- for(int c=0;c<13;c++)
- {
- temp=names[c];
- if(temp==nameSearch)
- {
- cout<<temp<<" was found at position "<<c+1<<endl;
- break;
- }
- else if(temp!=nameSearch&&c>11)cout<<"Name not found!"<<endl;
- }
- string strSearch;
- cout<<"Enter a search string: ";
- cin>>strSearch;
- bool isFound=false;
- for(int c=0;c<13;c++)
- {
- int num=names[c].find(strSearch);
- if(num!=-1)
- {
- cout<<names[c]<<", ";
- isFound=true;
- }
- }
- if(isFound==false)cout<<"Search string not found!";
- cout<<"\nNames in descending order"<<endl;
- string hold="";
- for(int c=0;c<13;c++)
- {
- for(int x=0;x<13;x++)if(names[x]<names[x+1])
- {
- hold=names[x];
- names[x]=names[x+1];
- names[x+1]=hold;
- }
- }
- for(int c=0;c<13;c++)cout<<names[c]<<", ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment