Question 1807: Element insertion

Source: Internet
Author: User

Print? Description
 
 
Mr. true
Mr. true is a super Superman who is engaged in competitions in high school and universities, and MS also needs such talents.
So, needless to say, when he goes to the interview, he will get a little bit of privilege, that is, he can leave the team for a while-pretty hr mm will arrange a front position for him.
 
 
Input
 
The first act is an integer T, indicating that there are T groups of data.
Each group has three rows of data:
First, the number of people in the original team is N;
There are n integers separated by spaces in the second line to represent the sequence of original team interview numbers;
The third behavior contains two integers: P and Q. P indicates the interview number obtained by Mr. true, and Q indicates that Mr. true will be inserted into the Q position of the team.
Ensure that no number is the same and N is not greater than 10000
 
Output
 
Number of the inserted team interview.
 
Sample Input
 
 
2
3
1 2 3
4 2
4
9 8 2 3
7 1
 
Sample Output
 
 
1 4 2 3
7 9 8 2 3

Description


Mr. true
Mr. true is a super Superman who is engaged in competitions in high school and universities, and MS also needs such talents.
So, needless to say, when he goes to the interview, he will get a little bit of privilege, that is, he can leave the team for a while-pretty hr mm will arrange a front position for him.


Input

The first act is an integer T, indicating that there are T groups of data.
Each group has three rows of data:
First, the number of people in the original team is N;
There are n integers separated by spaces in the second line to represent the sequence of original team interview numbers;
The third behavior contains two integers: P and Q. P indicates the interview number obtained by Mr. true, and Q indicates that Mr. true will be inserted into the Q position of the team.
Ensure that no number is the same and N is not greater than 10000

Output

Number of the inserted team interview.

Sample Input


2
3
1 2 3
4 2
4
9 8 2 3
7 1

Sample Output


1 4 2 3
7 9 8 2 3
 


[Plain] # include <stdio. h>
 
Int SUM (int num );
 
Int main ()
{
Int I;
Int j;
Int n;
Int m;
Int t;
Int k;
Int p;
Int q;
Int num [10001];

Scanf ("% d", & n );
 
While (n --)
{
Scanf ("% d", & m );
For (I = 0; I <m; I ++)
{
Scanf ("% d", & num [I]);
}
Scanf ("% d", & p, & q );
 
For (I = 0; I <q; I ++)
{
If (I = q-1)
{
T = num [I];
Num [I] = p;
 
For (j = I + 1; j <= m; j ++)
{
K = num [j];
Num [j] = t;
T = k;
}
}
}
 
For (I = 0; I <= m; I ++)
{
Printf ("% d", num [I]);
If (I <m)
{
Printf ("");
}
}
If (n> 0)
{
Printf ("\ n ");
}
}
Return 0;
}

# Include <stdio. h>

Int SUM (int num );

Int main ()
{
Int I;
Int j;
Int n;
Int m;
Int t;
Int k;
Int p;
Int q;
Int num [10001];

Scanf ("% d", & n );

While (n --)
{
Scanf ("% d", & m );
For (I = 0; I <m; I ++)
{
Scanf ("% d", & num [I]);
}
Scanf ("% d", & p, & q );

For (I = 0; I <q; I ++)
{
If (I = q-1)
{
T = num [I];
Num [I] = p;

For (j = I + 1; j <= m; j ++)
{
K = num [j];
Num [j] = t;
T = k;
}
}
}

For (I = 0; I <= m; I ++)
{
Printf ("% d", num [I]);
If (I <m)
{
Printf ("");
}
}
If (n> 0)
{
Printf ("\ n ");
}
}
Return 0;
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.