ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2100. Wedding Dinner

В чем разница
Posted by Olegkyz 20 Feb 2019 13:01
Когда использую циклы такого вида выдает ошибку Runtime error (non-zero exit code)

i=n;
while(i>0) {
    name[i]=calloc(1,30);
    scanf(" %s",name[i]);
    i--;
}
i=n;
while(i>0) {
    char *buf=name[i];
    while(*buf!='\0') {
        if(*buf=='+') {
            kol++;
            break;
        } else {
            buf++;
        }
    }
    i--;
}

А здесь AC
for(i=0;i<n;i++) {
    name[i]=calloc(1,30);
    scanf(" %s",name[i]);
}
for(i=0;i<n;i++) {
    char *buf=name[i];
    while(*buf!='\0') {
        if(*buf=='+') {
            kol++;
            break;
        } else {
            buf++;
        }
    }
}