File tree Expand file tree Collapse file tree 3 files changed +71
-0
lines changed
Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change 1+ #include <iostream>
2+ #include<string>
3+ using namespace std;
4+ int hammingDistance(string str1,string str2)
5+ {
6+ int c;
7+ c=0;
8+ if(str1.size() !=str2.size())
9+ {
10+ return -1;
11+ }
12+ else
13+ {
14+ for(int i=0;i<str1.size();i++)
15+ {
16+ if(str1[i]!=str2[i])
17+ {
18+ c++;
19+ }
20+ }
21+ }
22+ return c;
23+
24+ }
25+ int main() {
26+ string str1,str2;
27+ cin>>str1;
28+ cin>>str2;
29+ cout<<"Hamming Distance = "<<hammingDistance(str1,str2);
30+ return 0;
31+ }
Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ #include < algorithm>
3+ using namespace std ;
4+
5+
6+ int main ()
7+ {
8+ string str1;
9+ cin >> str1;
10+ int count = 0 ;
11+ for (int i = 0 ; i < str1.size (); i++)
12+ {
13+ if (str1[i] == ' a' || str1[i] == ' e' ||str1[i] == ' i' || str1[i] == ' o' ||str1[i] == ' u' )
14+ {
15+ count++;
16+ }
17+ }
18+ cout << " Vowels are:" << count;
19+ return 0 ;
20+ }
Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ #include < algorithm>
3+ using namespace std ;
4+
5+
6+ int main ()
7+ {
8+ string str1;
9+ cin >> str1;
10+ int count = 0 ;
11+ for (int i = 0 ; i < str1.size (); i++)
12+ {
13+ if (str1[i] == ' a' || str1[i] == ' e' ||str1[i] == ' i' || str1[i] == ' o' ||str1[i] == ' u' )
14+ {
15+ count++;
16+ }
17+ }
18+ cout << " Vowels are:" << count;
19+ return 0 ;
20+ }
You can’t perform that action at this time.
0 commit comments