YTU 2889: B--字母数字大战

来源:互联网 发布:淘宝的台式机能用多久 编辑:程序博客网 时间:2024/06/03 20:26

Description

字母数字发生了战争,决定要分家,各自调选自己的家族成员。如果一个字符串仅由数字构成的那么属于dight家族;如果是仅由字母构成的那么属于letter家族;如果是由数字和字母一起构成的那么属于mixed家族。

Input

输入一个字符串,长度不超过100,且字符串中只能包括数字或大、小写字母。

Output

输出该字符串的家族类型。

Sample Input

123456ff123a8

Sample Output

mixed

HINT

注意多组数据

Source

LDF

ac代码:

#include <iostream>#include <cstring>using namespace std;void fun(string str){    int len=str.length();    int n=0,s=0;    for(int i=0;i<len;i++){        if(str[i]>='0'&&str[i]<='9')            n++;        if(str[i]>='A'&&str[i]<='Z')            s++;        if(str[i]>='a'&&str[i]<='z')            s++;    }    if(n==0&&s!=0)cout<<"letter\n";    if(n!=0&&s==0)cout<<"dight\n";    if(n!=0&&s!=0)cout<<"mixed\n";}int main(){    string str;    while(getline(cin,str)){        fun(str);    }    return 0;}
运行结果:



0 0
原创粉丝点击