68 109 1611 1614 1510 147 11Example Output
1,5,4
01 | #include<stdio.h> |
02 | struct dog |
03 | { |
04 | int s, e; |
05 | int num; |
06 | } a[101], t; |
07 | int main() |
08 | { |
09 | int n, i, j, min; |
10 | scanf ( "%d" , &n); |
11 | for (i = 0; i < n; i++) |
12 | { |
13 | scanf ( "%d%d" , &a[i].s, &a[i].e); |
14 | a[i].num = i + 1; |
15 | } |
16 | for (i = 0; i < n - 1; i++) |
17 | { |
18 | for (j = i + 1; j < n; j++) |
19 | { |
20 | if (a[i].e > a[j].e) |
21 | { |
22 | t = a[i]; |
23 | a[i] = a[j]; |
24 | a[j] = t; |
25 | } |
26 | } |
27 | } |
28 | printf ( "%d" , a[0].num); |
29 | min = a[0].e; |
30 | for (i = 1; i < n; i++) |
31 | { |
32 | if (a[i].s >= min) |
33 | { |
34 | printf ( ",%d" , a[i].num); |
35 | min = a[i].e; |
36 | } |
37 | } |
38 | printf ( "/n" ); |
39 | return 0; |
40 | } |
68 109 1611 1614 1510 147 11Example Output
1,5,4
新闻热点
疑难解答