-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.cpp
More file actions
33 lines (33 loc) · 806 Bytes
/
simple.cpp
File metadata and controls
33 lines (33 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <bits/stdc++.h>
using namespace std;
int main()
{
string input1;
int input2;
getline(cin, input1);
cin >> input2;
cout << input1.length() << "\n";
input1 = input1 + ' ';
cout << input1.length() << "\n";
int count = 0;
string s2 = "";
for (int i = 0; i < input1.length(); i++)
{
//store each word
if (input1[i] != ' ')
s2 = s2 + input1[i];
else
{
string s1 = s2;
reverse(s1.begin(), s1.end());
reverse(s1.begin(), s1.begin() + input2);
reverse(s1.begin() + input2, s1.end());
cout << s1 << " " << s2 << endl;
if (s1.compare(s2) == 0)
count++;
s2 = "";
}
}
cout << count << "\n";
return 0;
}