TOPIC

I'm having a 5% error.Can anyone help me???

Eightletters asked 9 months ago

include

int main() { int a,b,q,r; scanf("%d %d",&a,&b);

q=a/b;
r=a%b;

if(a<0 && b>0){
    q=q-1;
    r=r+b;
}

if(a<0 && b<0){
    q=q+1;
    r=r-b;
}

printf("%d %d\n",q,r);

return 0;

}

Remember not post solutions. Your post may be reviewed by our moderators.

  • Tarcísio Mazur Junior replied 9 months ago

    #Inputs
    6 3
    6 -3
    -6 -3
    -6 3
    #Correct Output
    2 0
    -2 0
    2 0
    -2 0
    #Your Output
    2 0
    -2 0
    3 3
    -3 3
    MOD
  • Eightletters replied 9 months ago

    Still showing 5% WA....

    include

    int main() {

    int a,b,q,r;
    scanf("%d %d",&a,&b);
    
    q=a/b;
    r=a%b;
    
    if(r<0){
        q=q+1;
        r=r-b;
    }
    
    printf("%d %d\n",q,r);
    
    return 0;

    }