HDU 5166(缺失数查找输出)

HDU 5166

Time Limit:1000MS  Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

There is a permutation without two numbers in it, and now you know what numbers the permutation has. Please find the two numbers it lose.

Input

There is a number (T) shows there are (T) test cases below. (0<=T <=10) 
For each test case , the first line contains a integers \(n\) , which means the
number of numbers the permutation has. In following a line , there are $n$
distinct postive integers.(1 <=n <=1,000)

Output

For each case
output two numbers , small number first.

Sample Input

2

3

3 4 5

1

1

Sample Output

1 2

2 3

题解:找出一个数列中缺的两个数(这两个数要为最小的两个数)。

注意:利用bool函数把数组中所有数全部返回0

#include<stdio.h>
int main()
{
int T,i;
scanf("%d",&T);
while(T--)
{
int count,t=,j[];;
scanf("%d",&count);
bool flag[]={ false };
for( i=;i<=count;i++)
{
int tem;
scanf("%d",&tem);
flag[tem]=true;//每输入一个数s,便给第s个赋值为1
} for(i=;i<=count+;i++)
{
if(flag[i]==)//如果有为0的出现,则为缺失的数
{
j[t++]=i;
}
}
printf("%d %d\n",j[],j[]); }
return ;
}

多多交流~

上一篇:UVa 10883 (组合数 对数) Supermean


下一篇:Oracle EBS-SQL (OM-6):打开订单.sql