#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int* Select_Sort(int* a, int num);
void Swap(int* a, int* b);
int main()
{
int i = 0, j,count = 0;
int length;
int Insert, Delet;
int number_temp[10000];
int number[10000];
int Insert_number[10001];
int Delet_number[10001];
next:
while (scanf("%d", &number_temp[count]) != EOF){
if (number_temp[count] == -1) break;
number[count] = number_temp[count];
count++;
}
length = count;
count = 0;
scanf("%d", &Insert);
scanf("%d", &Delet);
Select_Sort(number,length);
//打印排序后的输出
if (length == 0){
printf("No elements.");
}
else{
for (j = 0; j < length; j++){
printf("%d", number[j]);
if ( j < length - 1) printf(",");
}
}
printf("\n");
for (i = 0; i < length; i++){
Insert_number[i] = number[i];
}
Insert_number[length] = Insert;
Select_Sort(Insert_number, length + 1);
//打印插入后的数据
for (j = 0; j < length+1; j++){
printf("%d", Insert_number[j]);
if (j < length) printf(",");
}
printf("\n");
//开始删除操作
int Delet_flag = 0;
for (i = 0; i < length+1; i++){
if (Insert_number[i] != Delet){
Delet_number[Delet_flag] = Insert_number[i];
Delet_flag++;
}
}
if (Delet_flag == 0) printf("No elements.");
else{
for (i = 0; i < Delet_flag; i++){
printf("%d", Delet_number[i]);
if (i < Delet_flag - 1) printf(",");
}
}
printf("\n");
goto next;
}
int* Select_Sort( int *a, int num)
{
int i,j;
for (j = 0; j < num; j++){
for (i = j; i < num; i++){
if (a[i] < a[j]) //选择排序,每次遍历都把最小的放到最前面
Swap(&a[i],&a[j]);
}
}
return a;
}
void Swap(int* a, int* b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}