Показать сообщение отдельно

  #2  
Старый 06.02.2008, 00:34
Forcer
Постоянный
Регистрация: 12.04.2007
Сообщений: 413
Провел на форуме:
3578578

Репутация: 275
Отправить сообщение для Forcer с помощью ICQ
По умолчанию

Код:
 #include <iostream> 
#include <list> 
#include <string> 
using namespace std; 

struct Someshit 
{ 
        string name; 
        int id; 
}; 
int main(int argc, char *argv[]) 
{ 
        Someshit some; // здесь изменено - убрана переменная tmp
        list <Someshit> somelist; 
        some.name="aa"; 
        somelist.push_back(some); 
        some.name="bb"; 
        somelist.push_back(some); 
        some.name="cc"; 
        somelist.push_back(some); 
        //и подобного много раз 
        list <Someshit>::iterator listpos; 
        int i = 0; 
        for (listpos = somelist.begin(); listpos != somelist.end(); listpos++) 
        {                 
                i++; 
                if (listpos->name == "bb") cout << i << " BB найдено \n"; // здесь изменено
                if (listpos->name[0] == 'c') cout << i << " первая C найдена \n"; // здесь изменено
        } 
        return 0; 

}
 
Ответить с цитированием