c语言90分求助,#4#17WA,4中给的数据为何没有输出
查看原帖
c语言90分求助,#4#17WA,4中给的数据为何没有输出
1192626
JIUZHOU1楼主2024/3/6 20:13
#include <stdio.h>
struct job{
    int dir;
    char name[20];
}a[100005];
int main(){
    long long int n,m;
    long long int j,k;
    int count=0;
    scanf("%lld %lld",&n,&m);
    
    for(int i=0;i<n;i++){
        scanf("%d %s",&a[i].dir,a[i].name);
}

    for(int l=0;l<m;l++){
        scanf("%lld %lld",&j,&k);
        if(k!=0){
        if(a[count].dir==j){
          int temp1=count-k;
          if(temp1>=0){
              count=temp1;
          }else{
              count=n+temp1;
          }
        }else{
            int temp2=count+k-n;
            if(temp2<=0){
                count=count+k;
            }else{
                count=temp2;
            }
        }
        }
    }
    
    printf("%s",a[count].name);
}
2024/3/6 20:13
加载中...