// File: map1.cpp // // Simple use of STL map container class // #include #include #include #include using namespace std ; int main() { map T ; T["George Washington"] = 1 ; T["John Adams"] = 2 ; T["Thomas Jefferson"] = 3 ; T["James Madison"] = 4 ; T["James Monroe"] = 5 ; T["John Quincy Adams"] = 6 ; T["Andrew Jackson"] = 7 ; T["Martin Van Buren"] = 8 ; T["William Henry Harrison"] = 9 ; T["John Tyler"] = 10 ; T["James Knox Polk"] = 11 ; T["Zachary Taylor"] = 12 ; T["Millard Fillmore"] = 13 ; T["Franklin Pierce"] = 14 ; T["James Buchanan"] = 15 ; T["Abraham Lincoln"] = 16 ; T["Andrew Johnson"] = 17 ; T["Ulysses Simpson Grant"] = 18 ; T["Rutherford Birchard Hayes"] = 19 ; T["James Abram Garfield"] = 20 ; T["Chester Alan Arthur"] = 21 ; T["Grover Cleveland"] = 22 ; T["Benjamin Harrison"] = 23 ; T["Grover Cleveland"] = 24 ; T["William McKinley"] = 25 ; T["Theodore Roosevelt"] = 26 ; T["William Howard Taft"] = 27 ; T["Woodrow Wilson"] = 28 ; T["Warren Gamaliel Harding"] = 29 ; T["Calvin Coolidge"] = 30 ; T["Herbert Clark Hoover"] = 31 ; T["Franklin Delano Roosevelt"] = 32 ; T["Harry S. Truman"] = 33 ; T["Dwight David Eisenhower"] = 34 ; T["John Fitzgerald Kennedy"] = 35 ; T["Lyndon Baines Johnson"] = 36 ; T["Richard Milhous Nixon"] = 37 ; T["Gerald Rudolph Ford"] = 38 ; T["James Earl Carter"] = 39 ; T["Ronald Wilson Reagan"] = 40 ; T["George Herbert Walker Bush"] = 41 ; T["William Jefferson Clinton"] = 42 ; T["George Walker Bush"] = 43 ; map::iterator it ; pair p ; for(it = T.begin() ; it != T.end() ; it++) { p = *it ; cout << p.first << " is President #" << p.second << "\n" ; } }