-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloj1166.cpp
49 lines (41 loc) · 895 Bytes
/
loj1166.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using namespace std;
#include<iostream>
#include<cstdio>
#include<cstring>
int main()
{
int T,arr[110],n,temp,count,Case=1,i,j,MIN;
scanf("%d",&T);
while(T--)
{
count=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
for(i=0;i<n-1;i++)
{
MIN=i;
for(j=i;j<n;j++)
{
if(arr[MIN]>arr[j])
MIN=j;
}
if(MIN!=i)
{
temp=arr[MIN];
arr[MIN]=arr[i];
arr[i]=temp;
count++;
}
}
printf("Case %d: %d\n",Case++,count);
}
return 0;
}
/*if(arr[i]>arr[j])
{
temp=arr[j];
arr[j]=arr[i];
arr[i]=temp;
count++;
}*/