#30962: C++ 8934line 答案0A0B 我的0A2B


ahankeu90@gmail.com (Ooscot克特)


如題,已經試過很多組大家提供的測資都沒問題,唯獨這個,不知道程式碼哪裡出問題。

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int ans[5];
    int n,Try[5],A=0,B=0;

    while(scanf("%d %d %d %d",&ans[1],&ans[2],&ans[3],&ans[4])!=EOF){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cin>>n;
    for(int i=1; i<=n; i++)
    {
        A=0;
        B=0;
        bool check[5][3];
        memset(check,0,sizeof(check));
        for(int j=1; j<=4; j++)
        {
            ios_base::sync_with_stdio(false);
            cin.tie(0);
            cin>>Try[j];
        }

        for(int a=1; a<=4; a++)
        {
                if(ans[a]==Try[a]){
                    A++;
                    check[a][1]=true;
                    check[a][2]=true;

                }
        }
        for(int a=1;a<=4;a++){
            for(int b=1;b<=4;b++){
                if(check[a][1]==true)
                    break;
                if(check[b][2]==true)
                continue;
                if(ans[a]==Try[b]){
                    B++;
                    check[b][2]=true;
                    break;

 

                }

            }    }printf("%dA%dB\n",A,B);
    }

    }
    return 0;
}

#31074: Re: C++ 8934line 答案0A0B 我的0A2B


cges30901 (cges30901)



        ios_base::sync_with_stdio(false);


io問題,你用了sync_with_stdio(false)就不能再混用scanf, printf這種stdio的函式