#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
string s;
cin >> s; //输入字符串
int sum = 0;
for (int i = 0; i < s.size(); i++)
{
if (isalnum(s[i])) //如果是字母或者数字据徐
{
continue;
}
else
{
cout << "it's not number or alphabet" << endl;
}
}
cout << s << endl;
}
2.isalpha(c)当C是字母为真
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
string s;
cin >> s; //输入字符串
int sum = 0;
for (int i = 0; i < s.size(); i++)
{
if (isalpha(s[i])) //如果是字母据徐
{
continue;
}
else
{
cout << "it's not number or alphabet" << endl;
}
}
cout << s << endl;
}
3.iscntrl(c)当c是控制字母时为真
4.isdigit(c)当c时数字为真
5.isgraph(c)当C不是空格但可打印时为真
6.islower(c)当C时小写字母为真
7.isprint(c)当C是可打印字符为真
8.ispunct(c)当C是标点符号为真
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
string s;
cin >> s; //输入字符串
int sum = 0;
for (int i = 0; i < s.size(); i++)
{
if (ispunct(s[i])) //统计有多少标点符号
{
sum++;
}
}
cout << sum << endl;
cout << s << endl;
}