'commit'
This commit is contained in:
23
TangDou/LuoGuBook/P1321.cpp
Normal file
23
TangDou/LuoGuBook/P1321.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include<bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
int boy, girl;//存放答案滴
|
||||
string x;
|
||||
|
||||
//这道题太无聊了~
|
||||
int main() {
|
||||
cin >> x;
|
||||
for (int i = 0; i < x.length(); i++) {
|
||||
//boy
|
||||
if (x[i] == 'b')boy++;
|
||||
if (x[i] == 'o' && x[i - 1] != 'b')boy++;
|
||||
if (x[i] == 'y' && x[i - 1] != 'o')boy++;
|
||||
//girl
|
||||
if (x[i] == 'g')girl++;
|
||||
if (x[i] == 'i' && x[i - 1] != 'g')girl++;
|
||||
if (x[i] == 'r' && x[i - 1] != 'i')girl++;
|
||||
if (x[i] == 'l' && x[i - 1] != 'r')girl++;
|
||||
}
|
||||
printf("%d\n%d", boy, girl);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user