I am solving Problem 'Red Light Green Light' with code 'DOLL' on Code chef.
Code Chef: Red Light Green Light
In this Problem, I need to take N inputs in one line. I tried using scanf() but to no avail, It didn't worked. It was talking N inputs in N line which isn't what I want. I tried using fgets and strtok. But There was some error coming which I am not understanding. So How can I do it?
void main(){
int T,N,K,sum_N=0;
int test_arr[N];
char name;
char *token;
scanf("%d",&T);
if(T<0||T>100000) printf("Wrong Input Cases"); // Condition Checking for T
if(sum_N>500000) printf("Exceeded Sum"); //Condition Checking for sum of N
while(T--){
scanf("%d %d",&N,&K);
if((N||K)<0||(N||K)>100000) printf("Wrong Values"); //Conditon Checking for N and K
// Here N Input in one Line are taken
fgets(name,sizeof(name),stdin);
token = strtok(name," ");
for(int i=0;i<N;i++){
test_arr[i] = *(token+i);
}
int ctr=0;
for(int i=0;i<N;i++){
if(test_arr[i]>K) ctr++;
}
printf("%d",ctr);
}
}