• hdu 2629 Identity Card string类用于c的字符串函数上


        这几天做ACM Step,比较不错,在做一道题的时候,我用的是string,函数用的是strncmp,说参数不匹配,看了看函数原型,参数是const char *,而我用的是string,需要转换一下:

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

     #include<iostream>



    using namespace std;
    int main()
    {
        
    int n,i,temp;
        
    char s[50];
        
    string regional[8]={"Zhejiang","Beijing","Taiwan","Hong Kong","Macao","Tibet","Liaoning","Shanghai"};
        
    string id[8= {"33""11""71""81""82""54""21""31"};
        cin
    >>n;

                     
    while(n--)
                     {
                               cin
    >>s;
                               cout
    <<"He/She is from ";
                               
    for(i=0;i<8;i++)
                               {
                                                
    if (strncmp(s, id[i].c_str(), 2== 0)
                                               {
                                                                cout
    <<regional[i];
                                                                
    break;
                                               }
                               }


                         cout
    <<",and his/her birthday is on "<<s[10]<<s[11]<<","<<s[12]<<s[13]<<","<<s[6]<<s[7]<<s[8]<<s[9]<<" based on the table."<<endl;

                 }

    }
  • 相关阅读:
    NHibernate中多表(对象)间的查询
    将datagrid数据导到excel的一个问题
    win2003<IIS6>部署.net 4.0<asp.net 4>
    C# 单元测试
    office2010 word发布博客 博客园
    语义化的HTML首先要强调HTML结构
    SQL Server 2005 安装(各种错误)
    SWFUpload V2.2.0 说明文档
    SQL Server 复制, 集群
    高亮插件测试
  • 原文地址:https://www.cnblogs.com/anderson0/p/2039679.html
Copyright © 2020-2023  润新知