problem in taking mixing inputs

I am trying to solve some problem. problem having test cases and inputs like some inputs are integer and some are character type. when I am correctly read integer inputs but when I am taking char type inputs then program is running out of control and abort abnormally. I think it doesn’t read input correctly and doesn’t execute accordingly.Please help. thanks in advance.Currently i am doing coding in c++.

@todumanish can you share the link of the question.

I am sharing same type but very very trivial problem in this type of question how can i take the input in specific manner http://www.spoj.com/problems/HS12MBR/

for the question(link) input can be taken as:

scanf("%d",&t);
while(t--){
	p=c=l=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%c",&ch); // to read new line character
		scanf("%c",&ch); // to read input character
		if(ch=='p'){
			scanf("%d%d",&x[p],&y[p]);
			p++;
		}else if(ch=='c'){
			scanf("%d%d%d",&xc[c],&yc[c],&r[c]);
			c++;
		}else{
			scanf("%d%d%d%d",&x1[l],&y1[l],&x2[l],&y2[l]);
			l++;
		}
	}
	scanf("%c",&ch);// to read new line character present after every test case
}

@srd091If I want to take input like this
1 1 p
2 3 q
then

@todumanish you can take input as string using getline and then seperate digits and characters by extracting characters from string one by one.