I get exited with non-zero status in this code pq?

0
#include<stdio.h>

int main(){
int i,jog,rod,placar[500],ponto=0,p,maxPonto=0,vencedor=0,rodCopia;

  scanf("%d %d",&jog,&rod);

  rodCopia = rod;

  for(i=1;i<=jog;i++){
          scanf("%d",&p);
          placar[i]+=p;
       if(i==jog && rod>0){
         rod-=1;
         i = 0;
       }

  }
       for(i=1;i<=rodCopia;i++){
         if(maxPonto < placar[i]){
           maxPonto = placar[i];
           vencedor = i;
         }

       }


     printf(vencedor); 
    return 0;
    }
    
asked by anonymous 23.11.2017 / 01:06

1 answer

0

The problem in your code is in the starting part of the is from 1, the language C does not allow a vector to use the zero position null, so its first is, just as the second ignores the position 0 of the vector. To fix the problem start the i of for for 0 and instead of leaving "

24.11.2017 / 15:39