#include<iostream>
#include<string>
using namespace std;
bool isyidong(string str)
{
bool flag=false;
if(str[3]=='_'&&str[8]=='_'&&str[0]=='1'&&str.size()==13)
flag=true;
return flag;
}
bool isguding(string str)
{
bool flag=false;
if((str[0]=='6'||str[0]=='8')&&str[3]=='_'&&str.size()==9)
flag=true;
return flag;
}
int main()
{
string str;
cin>>str;
if(isyidong(str))
cout<<"MOBILE";
else if(isguding(str))
cout<<"PSTN";
else
cout<<"ERROER";
return 0;
}
本文介绍了一个简单的C++程序,用于识别输入字符串是否为中国移动号码或固定电话号码。通过两个布尔函数isyidong和isguding来判断号码类型,并根据不同类型输出相应的结果。
2998

被折叠的 条评论
为什么被折叠?



