A Brief Note On Computers

Submitted By Joseph-Carpenter
Words: 350
Pages: 2

#include <iostream>
#include <string>

using namespace std;

int repeatWords(string word,string words[], int length);

void sortWords(string word[], int length);

int main(){ int count=0; int ucount=0; string lastWord; string word[100]; string uniquewords[100]; cout <<"Please type in some words."<< endl <<"Type END and return when you are finished."<< endl;

while(true){ //cin words to array cin >> lastWord; if(lastWord.compare("END")==0) // check to see if "END" is entered break; count++; word[count]=lastWord; }

cout << endl << endl << "You typed the following " << count << " words: " << endl; //test 2 for(int i=0;i<=count;i++){ cout << word[i]; if(i!=count && i!=0) cout<<", "; for(int j=0;j<word[i].length();j++) //converting list of words to lower case if(word[i][j]>64 && word[i][j]<91) word[i][j]+=32; int j=0; bool unique=false; while(true){ if(uniquewords[j].compare(word[i])==0) break; if(uniquewords[j].empty()){ uniquewords[ucount]=word[i]; ucount++; break; } j++; } } cout << endl << endl << "You typed the following " << ucount << " unique words:" << endl; //test 3 for(int i=0;i<ucount;i++){ cout << uniquewords[i]; if(i+1<ucount) cout << ", "; }

cout << endl << endl << "Here are those same unique words sorted:" << endl; //test 4 sortWords(uniquewords,ucount); for(int i=0;i<ucount;i++){