麻烦帮我看看哪错了,1个小时找不出来

#include<stdio.h>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
int n,na,nb;
cin>>n>>na>>nb;
int a[200+5],b[200+5];
for(int i=1;i<=na;i++)
{
cin>>a[i];
}
for(int i=1;i<=nb;i++)
{
cin>>b[i];
}
int sa=0,sb=0,z=1,x=1;
for(int i=1;i<=n;i++)
{
if(a[z]==0&&b[x]==0){z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==0&&b[x]==1){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==0&&b[x]==2){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==0&&b[x]==3){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==0&&b[x]==4){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==1&&b[x]==0){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==1&&b[x]==1){z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==1&&b[x]==2){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==1&&b[x]==3){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==1&&b[x]==4){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==2&&b[x]==0){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==2&&b[x]==1){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==2&&b[x]==2){z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==2&&b[x]==3){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==2&&b[x]==4){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==3&&b[x]==0){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==3&&b[x]==1){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==3&&b[x]==2){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==3&&b[x]==3){z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==3&&b[x]==4){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==4&&b[x]==0){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==4&&b[x]==1){sa++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==4&&b[x]==2){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==4&&b[x]==3){sb++;z++;x++;if(z==na)z=1;if(x==nb)x=1;}
else if(a[z]==4&&b[x]==4){z++;x++;if(z==na)z=1;if(x==nb)x=1;}
}
cout<<sa<<' '<<sb;
return 0 ;
}

1 条评论

  • @ 2016-09-18 13:33:24

    错误已用*标出
    c++
    #include<stdio.h>
    #include<cstring>
    #include<iostream>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    int main(){
    int n,na,nb;
    cin>>n>>na>>nb;
    int a[200+5],b[200+5];
    for(int i=1;i<=na;i++)
    {
    cin>>a[i];
    }
    for(int i=1;i<=nb;i++)
    {
    cin>>b[i];
    }
    int sa=0,sb=0,z=1,x=1;
    for(int i=1;i<=n;i++)
    {
    if(a[z]==0&&b[x]==0){z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==0&&b[x]==1){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==0&&b[x]==2){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==0&&b[x]==3){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==0&&b[x]==4){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==1&&b[x]==0){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==1&&b[x]==1){z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==1&&b[x]==2){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==1&&b[x]==3){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==1&&b[x]==4){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==2&&b[x]==0){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==2&&b[x]==1){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==2&&b[x]==2){z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==2&&b[x]==3){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==2&&b[x]==4){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==3&&b[x]==0){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==3&&b[x]==1){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==3&&b[x]==2){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==3&&b[x]==3){z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==3&&b[x]==4){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==4&&b[x]==0){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==4&&b[x]==1){sa++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==4&&b[x]==2){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==4&&b[x]==3){sb++;z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    else if(a[z]==4&&b[x]==4){z++;x++;if(z==na*+1*)z=1;if(x==nb*+1*)x=1;}
    }
    cout<<sa<<' '<<sb;
    return 0 ;
    }

  • 1

信息

ID
1905
难度
3
分类
模拟 点击显示
标签
递交数
3539
已通过
1711
通过率
48%
被复制
18
上传者