編寫一個函數,計算字符串中含有的不同字符的個數。字符在ACSII碼範圍內(0~127),換行表示結束符,不算在字符裏。不在範圍內的不作統計。
輸入描述:
輸入N個字符,字符在ACSII碼範圍內。
輸出描述:
輸出範圍在(0~127)字符的個數。
輸入
abc
輸出
3
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
string s;
vector<char> v;
int count=0;
cin>>s;
for(int i=0;i<s.length();i++){
if(find(v.begin(),v.end(),s[i])==v.end()){
v.push_back(s[i]);
count++;
}
}
cout<<count<<endl;
return 0;
}