?? ep11_6.cpp
字號(hào):
/*11.4 使用映射(map),建立阿拉伯的數(shù)字0~9和英文單詞Zero到Nine的映射關(guān)系,
并輸入阿拉伯?dāng)?shù)字(如:1),輸出英文數(shù)字(如:One)。*/
#include<iostream.h>
#include<map>
using namespace std;
typedef map<int,char*> ismap;
int main(){
int i=1,j;
char* str[10]={"one","two","three","fore","five","six","sever","eight","nine","ten"};
ismap trans_map1;
ismap::iterator it;
for(i=1;i<=10;i++) trans_map1.insert(ismap::value_type(i,str[i-1]));
for(it=trans_map1.begin();it!=trans_map1.end();it++)
cout<<(*it).first<<'\t'<<(*it).second<<endl;
cout<<trans_map1.size()<<endl;
cout<<"請(qǐng)輸入1~10的數(shù)字:"<<endl;
cin>>j;
it=trans_map1.find(j);
cout<<(*it).first<<'\t'<<(*it).second<<endl;
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -