文章
47
粉丝
109
获赞
8
访问
29.6k
int main() {
int n = 0;
scanf("%d", &n);
int s[105] = { 0 };
int s_sort[105] = { 0 };
for (int i = 0; i < n; i++) {
scanf("%d", &s[i]);
s_sort[i] = s[i];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - 1 - i; j++) {
if (s_sort[j] > s_sort[j + 1]) {
int t = s_sort[j];
s_sort[j] = s_sort[j + 1];
s_sort[j + 1] = t;
}
}
}
int max = s_sort[n - 1];
int min = s_sort[0];
if (max == min) {//全都一样
for (int i = 0; i < n - 2; i++) {
printf("%d ", s[i]);
}
}
for (int i = 0; i < n; i++) {
if (s[i] != max && s[i] != min) {
printf("%d ", s[i]);
}
}
return 0;
}
难倒是不难,就是题目没说清楚全都一样该怎么删
登录后发布评论
暂无评论,来抢沙发