这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿;

题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了:

http://acm.hdu.edu.cn/showproblem.php?pid=2629

 1 #include <iostream>
 2 #include <string>
 3 using namespace std;
 4 int main()
 5 {
 6     int n,t;
 7     string home,a;
 8     cin>>n;
 9     for(int k = 0 ; k < n ; k++)
10     {
11         cin>>a;
12         t = (a[0]-'0')*10+a[1]-'0';
13         switch(t)
14         {
15             case 11:home = "Beijing";break;
16             case 31:home = "Shanghai";break;
17             case 21:home = "Liaoning";break;
18             case 33:home = "Zhejiang";break;
19             case 54:home = "Tibet";break;
20             case 71:home = "Taiwan";break;
21             case 81:home = "Hong Kong";break;
22             case 82:home = "Macao";break;
23             default :break;
24         }
25         cout<<"He/She is from "<<home<<",and his/her birthday is on "
26         <<a[10]<<a[11]<<","<<a[12]<<a[13]<<","<<a[6]<<a[7]<<a[8]<<a[9]
27         <<" based on the table."<<endl;
28     }
29     return 0;
30 }


 

相关文章:

  • 2021-08-22
  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2022-02-05
  • 2022-01-10
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2021-09-16
  • 2022-01-03
  • 2022-12-23
  • 2021-09-11
  • 2021-06-24
  • 2022-02-05
  • 2022-12-23
相关资源
相似解决方案