手机号码是一串数字,长度为11为,并且第一位必须是1,现在给出一个字符串,我们需要判断这个字符串是否符合手机格式
输入:输入是一个字符串
输出:若该字符串符合手机格式,输出1,否则输出0
样例输入
12345612345
样例输出
1 水题#include<string> #include<cstring> #include<iostream> #include<vector> using namespace std; int main() { string s; while(cin>>s) { int TOW=1; if(s.size()!=11) TOW=0; else if(s[0]!='1') TOW=0; else for(int i=1;i<=10;i++) if(s[i]<48||s[i]>57) TOW=0; cout<<TOW<<endl; } return 0; }