C++ (Qt)... QTextCodec *codec = QTextCodec::codecForName("CP-1251"); QTextCodec::setCodecForLocale(codec); QFile in( "C:/Projects/wordstat/test.txt" ); if( !in.open( QIODevice::ReadOnly | QIODevice::Text ) ) { qWarning( "Test file not found." ); return 1; } QTextStream inStream(&in); QString src = inStream.readAll();...
C++ (Qt) QHash<QString, int> frequencyHash; foreach (QString Item, itemList) ++frequencyHash[Item]; itemList.removeDuplicates(); int countItem(0); foreach (QString trimmedStr, itemList) { countItemFull = countItemFull + frequencyHash.value(trimmedStr); countItem = frequencyHash.value(trimmedStr); countItemString.setNum(countItem); trimmedStr = trimmedStr + "\t" + countItemString; frequencyList.prepend( trimmedStr ); }
C++ (Qt) foreach (QString s, itemList) frequencyList.prepend(s + "\t" + QString::Number(frequencyHash[s]));