提交时间:2022-08-03 14:42:37
运行 ID: 56792
#include<bits/stdc++.h> using namespace std; int d,g,z; void fun(char c){ if(c=='D') d++; if(c=='G') g++; if(c=='Z') z++; } void fun1(char c){ if(c=='D') d--; if(c=='G') g--; if(c=='Z') z--; } int main(){ int n,d=0,g=0,z=0; char c1,c2; for(int i=1;i<=n;i++){ cin>>c1>>c2; fun(c1); fun1(c2); } cout<<"D "<<d<<endl; cout<<"G "<<g<<endl; cout<<"Z "<<z<<endl; return 0; }