I have a problem which i need to check if a given list is daisy chained. Daisy chained list is list with strings in which the last letter of first element equals first letter of the next element. And the output is if there is that kind of elements in the list print them to console. The list size cant be less than 4 and more than 25 words. Maybe my problem is that i cant iterate through the list. I know the logic for the task but im not familiar with the list and it dont have operator[] so i dont know how to realize it. Here is my code:
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main()
{
int n;
cin >> n;
if (n < 4 || n > 25)
{
cout << "N cant be less than 4 and more than 25" << endl;
return 1;
}
list<string> li;
string line;
for (int i = 0; i < n; i++)
{
cin >> line;
li.push_back(line);
}
/*for (list<string>::iterator it = li.begin(); it != li.end(); it++)
{
cout << *it << " ";
}*/
for (list<string>::iterator it = li.begin(); it != li.end(); it++)
{
if ()
}
return 0;
}