链接:
题意
这也用看?
解:
这也用看?
实际代码:
#include<bits/stdc++.h>
using namespace std;
bool detectCapitalUse(string word)
{
int xx=0,dx=0,lg=word.length();
for(int i=0;i<lg;i++)
{
if(word[i]>='A' && word[i]<'a')//大写
{
dx++;
}
else if(word[i]>='a')//小写
{
xx++;
}
}
if((dx && !xx) || (!dx&&xx)) return true;
if(lg>1 && dx==1 && word[0]>='A' && word[0]<'a') return true;
return false;
}
int main()
{
string word;
cin>>word;
bool ans=detectCapitalUse(word);
cout<<ans<<endl;
return ans;
}
限制:
1 <= word.length <= 100
word
由小写和大写英文字母组成