Skip to content

Commit 8ec0bcf

Browse files
shubhendra-20MadhavBahl
authored andcommitted
Create day3_solve (#201)
* Create day3_solve Hamming Distance Problem * Add files via upload * Create day4_solve.cpp
1 parent 04df86a commit 8ec0bcf

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

Day3/day3_solve

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
}

day4/C++/day4_solve.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

day4/C++/day4_solved.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
}

0 commit comments

Comments
 (0)