mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1716.c
This commit is contained in:
parent
054a80ace0
commit
ada7deae0d
41
QUSTOJ/1716.c
Normal file
41
QUSTOJ/1716.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int cmp(const void* a,const void* b)
|
||||
{
|
||||
return *((int*)b)-*((int*)a);
|
||||
}
|
||||
|
||||
int p[1024];
|
||||
|
||||
int main()
|
||||
{
|
||||
int n,target;
|
||||
scanf("%d%d",&target,&n);
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
scanf("%d",&p[i]);
|
||||
}
|
||||
qsort(p,n,sizeof(int),cmp);
|
||||
int found=0;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
printf("%d ",p[i]);
|
||||
}
|
||||
printf("\n");
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
if(p[i]==target)
|
||||
{
|
||||
printf("%d\n",i+1);
|
||||
found=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
printf("-1\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user