简单题
给出身份证号 判断住址 和出生年月
熟练字符串的操作
主要是string::substr(s, l)//s:起始位置 l长度
1 #include <iostream> 2 #include <stdio.h> 3 #include <string> 4 #include <string.h> 5 #include <map> 6 #include <fstream> 7 8 using namespace std; 9 10 11 map<string,string> m; 12 int main() 13 { 14 m["33"] = "Zhejiang"; 15 m["11"] = "Beijing"; 16 m["71"] = "Taiwan"; 17 m["81"] = "Hong Kong"; 18 m["82"] = "Macao"; 19 m["54"] = "Tibet"; 20 m["21"] = "Liaoning"; 21 m["31"] = "Shanghai"; 22 int T; 23 freopen("in.txt", "r", stdin); 24 ifstream cin ("in.txt"); 25 scanf("%d", &T); 26 getchar(); 27 while (T--) 28 { 29 char buff[128]; 30 string id, from; 31 string yy, mm, dd; 32 gets(buff); 33 id = buff; 34 from = id.substr(0, 2); 35 yy = id.substr(6, 4); 36 mm = id.substr(10, 2); 37 dd = id.substr(12,2); 38 cout << "He/She is from " << m[from] << ",and his/her birthday is on " <<mm<<"," <<dd <<"," <<yy <<" based on the table."<<endl; 39 } 40 }