0
 string word = "abcde";
  int count = 0;
  for(int i = 0; i < word.length(); i++){
    for(int j = 1; j < word.length(); j++){
      if(word.at(i) == word.at(j)){
        count++;
      } 
    }
  }

i am trying to write a program that when i am given a string i can count letter pairs in the string so for example: cat returns 0 and doggy returns 1. this i what i have written now and i tried cout the loops and such but im still very lost in what i am doing wrong. any help would be very helpful

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Rzink92
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.