Write a program to check if an alphabet occurs twice continuously in an input string in java.
For ex Input:Rabbit
Output: Yes
b-2
Answers
Answered by
1
#include <bits/stdc++.h>
using namespace std:
int main() {
string str;
int count = 0;
cin >> str;
for (int i = 0; i<str.length()-1; i++) {
if (str.at(i)==str.at(i+1))
count++;
}
if (count>0)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
Similar questions