1 条题解

  • 0
    @ 2024-12-24 9:49:01

    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;
    }
    
    
    
    • 1

    信息

    ID
    809
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者