1 条题解

  • 0
    @ 2024-9-27 10:02:17

    C :

    #include<stdio.h>
    
    int main(){
    	int x[3]={0},n,i,cc,t;
    	char c;
    	scanf("%d",&n);
    	for(i=0;i<n;i++){
    		scanf("%d%c%d",&cc,&c,&t);
    		if(c=='Y'||c=='E'||c=='X')
    			x[cc]++;
    	}
    	printf("%d %d\n",x[1],x[2]);
    	return 0;
    }
    

    C++ :

    #include <iostream>
    
    using namespace std;
    
    string str;
    int numa,numb;
    void  init()
    {
        numa=0;
        numb=0;
    }
    int main()
    {
        int n;
        while(cin>>n)
        {
            init();
            for(int i=0;i<n;i++)
            {
                cin>>str;
                if(str[0]=='1'&&(str[1]=='Y'||str[1]=='E'||str[1]=='X'))
                {
                    numa++;
                }
                if(str[0]=='2'&&(str[1]=='Y'||str[1]=='E'||str[1]=='X'))
                {
                    numb++;
                }
            }
            cout<<numa<<" "<<numb<<endl;
        }
    
    
        return 0;
    }
    
    
    

    Pascal :

    var
      s:string;
      i,j,mt,qc,n:longint;
    begin
      readln(n);
      for i:=1 to n do
        begin
          readln(s);
          if (s[1]='1') and (s[2] in ['Y','E','X']) then
            inc(mt)
                else if (s[1]='2') and (s[2] in ['Y','E','X']) then
                    inc(qc);
                            
        end;
        write(mt,' ',qc)
    end.
      
    
    
    • 1

    信息

    ID
    585
    时间
    1000ms
    内存
    128MiB
    难度
    10
    标签
    递交数
    5
    已通过
    4
    上传者