Task Cho trước một xâu s, hãy đếm số lượng ký tự chữ cái phân biệt trong xâu không phân biệt hoa thường.
Input • Gồm một dòng duy nhất chứa xâu s có độ dài không quá 500 ký tự.
Output • In ra kết quả cần đếm.
Samples
input 1 picture wOrths 1000 of Words
output 13
Code:
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
int main()
{
char *s = new char[27];
gets(s);
int x = 0,b[100000],t = 0,count = 0;
for(int i = 0 ; i < strlen(s) ; i++)
b[x++] = (int)tolower(*(s+i));
for(int i = 0 ; i < strlen(s) ; i++)
{
char c = (int)tolower(*(s+i));
if(c >= 65 && c <= 90 || c >= 97 && c <= 122)
{
for(int j = 0 ; j < i + 1 ; j++)
{
if(c == b[j])
count++;
}
if(count == 1)
{
t++;
count = 0;
}
if(count > 1)
count = 0;
}
}
cout<<t;
return 0;
}