Question one hundred and eight: delete an element

Source: Internet
Author: User

Print? Description
 
David Deng accompanied Mr. true & Eddy for the interview.
David Deng is confident to go to Microsoft for an interview. A group of interviewers have a long queue, and each has an interview number.
At this moment, a big beauty KZ walked by him. David Deng fell in love with him at first sight. David Deng picked up his interview number N and left the interview team.
 
Input
 
The first act is an integer T, indicating that there are T groups of data.
Each group has three data rows:
The first line is an integer M, indicating that the original team has M members;
There are M integers separated by spaces in line 1, that is, the interview number of each person in the original team;
The interview number N of the third behavior David Deng.
Ensure that no number is the same and N is not greater than 10000
 
Output
 
The sequence of interview numbers of the team after David Deng leaves.
 
Sample Input
 
 
1
4
1 3 8 2
3

Description

David Deng accompanied Mr. true & Eddy for the interview.
David Deng is confident to go to Microsoft for an interview. A group of interviewers have a long queue, and each has an interview number.
At this moment, a big beauty KZ walked by him. David Deng fell in love with him at first sight. David Deng picked up his interview number N and left the interview team.

Input

The first act is an integer T, indicating that there are T groups of data.
Each group has three data rows:
The first line is an integer M, indicating that the original team has M members;
There are M integers separated by spaces in line 1, that is, the interview number of each person in the original team;
The interview number N of the third behavior David Deng.
Ensure that no number is the same and N is not greater than 10000

Output

The sequence of interview numbers of the team after David Deng leaves.

Sample Input


1
4
1 3 8 2
3
 


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

Scanf ("% d", & n );
 
While (n --)
{
Scanf ("% d", & m );
For (I = 0; I <m; I ++)
{
Scanf ("% d", & num [I]);
}
Scanf ("% d", & p );
 
For (I = 0; I <m-1; I ++)
{
If (num [I] = p)
{
For (j = I; j <m-1; j ++)
{
Num [j] = num [j + 1];
}
}
}
 
For (I = 0; I <m-1; I ++)
{
Printf ("% d", num [I]);
If (I <m-2)
{
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 p;
Int num [10001];

Scanf ("% d", & n );

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

For (I = 0; I <m-1; I ++)
{
If (num [I] = p)
{
For (j = I; j <m-1; j ++)
{
Num [j] = num [j + 1];
}
}
}

For (I = 0; I <m-1; I ++)
{
Printf ("% d", num [I]);
If (I <m-2)
{
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.