学べない学校 [MISSION LEVEL: C]

 1 #include <bits/stdc++.h>
 2 #define _for(i,a,b) for(int i = (a);i < (b);i ++)
 3 #define pb push_back
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     int n;
 9     while(cin >> n)
10     {
11         int c1 = 0,c2 = 0;
12         _for(i,0,n)
13         {
14             char a,b;
15             cin >> a >> b;
16             if(a!=b)
17             {
18                 if(a=='g'&&b=='c')
19                     c1 ++;
20                 if(a=='g'&&b=='p')
21                     c2 ++;
22                 if(a=='c'&&b=='g')
23                     c2 ++;
24                 if(a=='c'&&b=='p')
25                     c1 ++;
26                 if(a=='p'&&b=='g')
27                     c1 ++;
28                 if(a=='p'&&b=='c')
29                      c2 ++;
30             }
31         }
32         cout << c1 << endl << c2 << endl;
33     }
34     return 0;
35 }
原文地址:https://www.cnblogs.com/Asurudo/p/10313027.html