I'm having this issue while trying to solve this question on HackerRank. On repl.it my code goes well, but on their console i have this problem.
Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int t; //qtd de viagens
int m; //dinheiro para os sorvetes
int n; //qtd de sabores de sorvetes
int c[n+1]; //preço de cada sorvete
int r[t];
int s[t];
scanf("%d", &t);
for(int j = 0; j < t; j++){
scanf("%d", &m);
scanf("%d", &n);
for(int i = 1; i <= n; i++){
scanf("%d", &c[i]);
}
for (int i = 1; i < n; i++){
for(int k =i+1; k <= n; k++){
if (c[i]+c[k] == m){
r[j] = i;
s[j] = k;
}
}
}
}
for(int i = 0; i < t; i++){
printf("%d %d\n", *&r[i], *&s[i]);
}
return 0;
}
Input:
2
4
5
1 4 5 3 2
4
4
2 2 4 3
Output on repl.it:
1 4
1 2
Output on HackerRank:
~ no response on stdout ~
It also gives me a Segmentation Fault message.