【杭电100题】2081 手机短号

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2081
之前就遇到过输入单个数字的题,这次写的时候又忘了
需要写cin.get()-‘0’,按字符输入,然后转化成数字

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[12];
    while(n--)
    {
        getchar();
        for(int i=1; i<=11; i++)
            a[i]=cin.get()-'0';
        cout<<'6';
        for(int j=7; j<=11; j++)
            cout<<a[j];
        cout<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41727666/article/details/88422500