/////////////////////////////////////////////////////////////// // iter1b.cpp -- first STL iterator demo // // // // compiles with Visual C++ 5.0 // // won't compile with Borland 5.0 // // Jim Fawcett, 4/4/98 // /////////////////////////////////////////////////////////////// #include #include #include #include #include using namespace std; void main() { cout << " using pair defined in std::utility\n"; vector< pair > vc; vc.push_back(pair( 1, 0)); vc.push_back(pair( 1, 1)); vc.push_back(pair( 0, 1)); vc.push_back(pair(-1, 1)); vc.push_back(pair(-1, 0)); vc.push_back(pair(-1,-1)); vc.push_back(pair( 0,-1)); vc.push_back(pair( 1,-1)); vc.push_back(pair( 1, 0)); const double pi = 3.1415927; vector< pair >::iterator vci; double angle; for(vci=vc.begin(); vci != vc.end(); vci++) { angle = atan2(vci->second,vci->first)*(180.0/pi); cout << " " << "(" << setw(2) << (*vci).first << "," << setw(2) << (*vci).second << ")" << setw(6) << angle << "\n"; } cout << endl; }