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 1197. Lonesome Knight

Why the "for" stopped
Posted by Lucas 5 Jan 2017 07:04
'n' is the number of test cases and 'res' it's a function that print the number of positions that can go.

The problem is that it only reads one case, for example "a2", prints the result and ends the execution.

Why that happen?

void res(char p[2]);
int main () {
int i,n;
char pos[2];
scanf("%d", &n);
for(i=0; i<n; i++) {
    scanf("%s", &pos);
    res(pos);
}

Edited by author 05.01.2017 08:22
Re: Why the "for" stopped
Posted by ToadMonster 5 Jan 2017 11:34
You need at least 3 chars for pos - for ending zero char.
Probably it ruined n during first "scanf("%s", &pos);"