Think:
character string Judge the question , utilize ABC Of ascii Code difference processing ~~~

Problem Description

It's the annual Tangyuan Festival on Tangyuan planet , In the world of Tangyuan , There are many kinds of tangyuan , Like chocolate , Orange , Hami melon , Stinky feet .
Tangyuan people like to be with their own taste , So when you see dumplings together, they are usually in this format AnBnCn(A,B,C It represents the taste of tangyuan , And these three taste different ).
for example ,“ABC”,“AABBCC” It's all in line with the rules , Because the dumplings with the same taste are standing together . for example “AAA”,“AB”,“AABBCCC” It's all against the rules .
Input

Multiple sets of test data , No more than 25 group , Process to the end of the file .
Input has multiple lines , One string per line represents the sequence of Tangyuan standing together .
The length of the string 1 <= len <= 20.
The string contains only uppercase letters .
Output

For each group of test data , If the dumplings stand together, it's legal , output YES, Otherwise output NO.
Example Input

ABC
BC

Example Output

YES
NO

Hint

Hint:“ABC”,“AABBCC” It's all in line with the rules , Because it's consistent with AnBnCn The rules of , Namely n=1 and n=2.
“AAA”,“AB”,“AABBCCC” It's all against the rules ,“AAA”,“AB” Not satisfied ABC At the same time ,“AABBCCC” Not satisfied n It's the same .
Author
Casithy
#include<bits/stdc++.h> using namespace std; int main() { int i; int cnt1,
cnt2, cnt3;bool flag; char str[100]; while(cin >> str) { cnt1 = cnt2 = cnt3 = 0
; flag =0; int d = strlen(str); if (str[0] == 'A' && str[d - 1] == 'C') { for
(i =0; i <= d - 2; i ++) { if (str[i] < 'A' || str[i] > 'C' || str[i + 1] < 'A'
||str[i + 1] > 'C') { flag = 0; break; } else { if ((str[i + 1] - str[i] >= 0)
&& (str[i + 1] - str[i] <= 1)) { flag = 1; if (str[i] == 'A') cnt1 ++; if (str
[i] =='B') cnt2 ++; if (str[i] == 'C') cnt3 ++; } else { flag = 0; break; } } }
if (str[d - 1] == 'A') cnt1 ++; if (str[d - 1] == 'B') cnt2 ++; if (str[d - 1]
=='C') cnt3 ++; } if (flag == 1 && cnt1 == cnt2 && cnt2 == cnt3) cout << "YES"
<< endl;else cout << "NO" << endl; } }

Technology
©2020 ioDraw All rights reserved
PHP call shell command Did you complain today ? Self made whole person computer program Comparison of data extraction tools :Kettle,Datax,Sqoop,StreamSetsKeras Output the results of each layer of the model Feature Engineering After the outbreak Which programming has a bright future Children programming children's learning route java properties Profile tool class Android Development — Display food information according to customer budget