I've been trying different compilers available on the Codeforces submission page but none of the different compilers is giving an output such as Code::Block's
Problem link: https://codeforces.com/problemset/problem/282/A
Here is my code:
#include <stdio.h>
#include <string.h>
int main() {
int count = 0, i = 0, final;
int x = 0;
char strg[3];
scanf("%d", &count);
for (i = 0; i < count; i++){
scanf("%s", &strg[0], &strg[1], &strg[2]);
if ((strcmp(strg,"x++") == 0) || (strcmp(strg,"++x") == 0)){
x = x+1;
} if ((strcmp(strg,"x--") == 0) || (strcmp(strg,"--x") == 0)){
x = x-1;
}
}
printf("%d", x);
}
Submission page output: "wrong answer 1st numbers differ - expected: '1', found: '0'" However, Code::Blocks prints the correct value which is "1".
Codeforces submission:
Program running output:


'\0'. But since your variable has only space for 3 characters, the used test checker might put anything after the third character. -- Another quirk: Why are you providing three target arguments for just one format specifier at your call ofscanf()? Additionally, you should check its return value.printf()has a completely different meaning than the return value ofscanf(). Please read its documentation. -- Another thing to consider: Are you sure that "x" is lower case?printf("\"%s\"\n", strg);