zoukankan      html  css  js  c++  java
  • 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;

                 }

    }
  • 相关阅读:
    消息传递协议
    TSL 访问器
    graph engine
    uwp 动画Storyboard
    iOS播放视频时候,忽略设备静音按钮
    Could not find Developer Disk Image
    GIT常用命令
    iOS 音频播放时听筒及扬声器切换
    iOS 9:ATS
    iOS设计模式
  • 原文地址:https://www.cnblogs.com/anderson0/p/2039679.html
Copyright © 2011-2022 走看看