Skip to content

Instantly share code, notes, and snippets.

@aoloe
Created September 22, 2015 20:32
Show Gist options
  • Save aoloe/6f3997e919d677423916 to your computer and use it in GitHub Desktop.
Save aoloe/6f3997e919d677423916 to your computer and use it in GitHub Desktop.
exercise 19, chapter 4, programming c++
// type names and scores
#include "std_lib_facilities.h"
int main(){
vector<string> names;
vector<int> scores;
string name;
int score;
while(true) {
cout<<"Please type a nmae with a score:\n";
cin>>name>>score;
bool isrepeted=false;
for(int i=0; i<names.size();++i)
if(name==names[i]){
cout<<"Repetition!\n";
isrepeted=true;
break;
}
if ((name=="NoName" && score==0) || isrepeted==true)
break;
names.push_back(name);
scores.push_back(score);
}
for (int i=0; i<names.size();++i)
cout<<names[i]<<"\t"<<scores[i]<<"\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment