2006-11-29から1日間の記事一覧

HugeDomains.com - Shop for over 300,000 Premium Domains

http://www.workmethod.com/

setコンテナで名前から電話番号を検索する例

#include <iostream> #include <string> #include <set> using namespace std; class CAddress { public: string m_strName; string m_strTel; CAddress(){} CAddress(const string& name, const string& tel) {m_strName = name; m_strTel = tel;} }; bool operator<(const CAddres</set></string></iostream>…

mapコンテナで名前から電話番号を検索する例

#include <iostream> #include <string> #include <map> using namespace std; int main() { map<string, string> mapAdrs; mapAdrs.insert(pair<string, string>("Anne", "1111-1111")); mapAdrs.insert(pair<string, string>("Charlie", "3333-3333")); mapAdrs.insert(pair<string, string>("Bob", "2222-2222")); mapAd…</string,></string,></string,></string,></map></string></iostream>

listコンテナを使った例

#include <stdio.h> #include <list> using namespace std; int main() { list<int> lst; list<int>::iterator p; int i; for(i = 1; i < 6; i++) lst.push_back(i); for(p = lst.begin(); p != lst.end(); p++) printf("%d ", *p); putchar('\n'); for(i = 1; i < 6; i++) lst.push_f</int></int></list></stdio.h>…

STLの反復子の種類

種類 サポートする演算子 ランダム・アクセス反復子 ->, *, =, +, -, ++, -, [], , =, +=, -=, ==, != 双方向反復子 ->, *, =, ++, -- 前方反復子 ->, *, =. ++, ==, != 入力反復子 ->, *, =, ++, ==, != 出力反復子 =, *, ++

反復子を使ってコンテナにアクセスする

#include <stdio.h> #include <vector> using namespace std; int main() { vector<int> vec(10); vector<int>::iterator p; p = vec.begin(); int i = 0; while(p != vec.end()){ *p++ = i++; } int sum = 0; for(p = vec.begin(); p != vec.end(); p++){ sum += *p; } printf("0+1+2+.</int></int></vector></stdio.h>…