#include <QCoreApplication>
#include <QString>
#include <QStringList>
#include <QDebug>
#include <QTime>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qsrand(QTime::currentTime().msec());
QStringList cities = QStringList()<<QString("Dublin")<<QString("Wicklow")<<QString("Norwich")<<QString("Liverpool")<<QString("Corby")<<QString("Luton")<<QString("Listowel");
QStringList matchCities;
foreach(QString city, cities)
{
if(!city.isEmpty())
{
if(city.endsWith(city[0], Qt::CaseInsensitive))
{
matchCities<<city;
}
}
}
int index = qrand()%matchCities.size();
qDebug()<<matchCities[index];
return a.exec();
}
#include <QCoreApplication>
#include <QString>
#include <QStringList>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QStringList cities = QStringList()<<QString("Dublin")<<QString("Norwich")<<QString("Liverpool")<<QString("Corby")<<QString("Luton");
foreach(QString city, cities)
{
if(!city.isEmpty())
{
if(city.endsWith(city[0], Qt::CaseInsensitive))
{
qDebug()<<city;
}
}
}
return a.exec();
}