回答編集履歴
1
追記
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
|
5
|
+
1.数値を10個入力
|
6
6
|
|
7
7
|
2.数値を降順でソート
|
8
8
|
|
@@ -75,3 +75,81 @@
|
|
75
75
|
}
|
76
76
|
|
77
77
|
```
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
以下追記
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
qsort()を使う場合
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
#include <stdio.h>
|
92
|
+
|
93
|
+
#include <stdlib.h>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
#define N 10
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
int a[N];
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
int f_cmp(const void* a, const void* b) {
|
106
|
+
|
107
|
+
if (*(int*)a < *(int*)b) {
|
108
|
+
|
109
|
+
return -1;
|
110
|
+
|
111
|
+
} else if ( *(int*)a == *(int*)b ) {
|
112
|
+
|
113
|
+
return 0;
|
114
|
+
|
115
|
+
} else {
|
116
|
+
|
117
|
+
return 1;
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
int main(void){
|
126
|
+
|
127
|
+
int i,j,tmp,max;
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
printf("入力\n");
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
for(i=0; i<N; i++) {
|
136
|
+
|
137
|
+
scanf("%d",&a[i]);
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
qsort((void*)a, N, sizeof(a[0]), f_cmp);
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
printf("入力に対応する出力\n");
|
148
|
+
|
149
|
+
printf("%d\n",a[7]);
|
150
|
+
|
151
|
+
return 0;
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
```
|