C:(0分)
按理说就是普通的冒泡排序
搞了好久没有搞定,输出好像也没有问题,不想搞了
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
int a, b;
int arr[100000];
int num = 0;
int temp = 0;
scanf("%d %d", &a, &b);
while (scanf("%d", &arr[num]) != EOF && getchar() != '\n') //输入多组中间有空格的数据
{
num++;
}
temp = 0;
//冒泡排序
for (int i = 0; i <= num - 1; i++)
{
for (int j = i; j < num; j++)
{
if (arr[i] > arr[j + 1])
{
temp = arr[i];
arr[i] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
for (int i = 0; i <= num; i++)
{
printf("%d", arr[i]);
if (i != num)
{
printf(" ");
}
}
return 0;
}
C++:(100分)
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int a, b;
int arr[2000001];
cin >> a >> b;
for (int i = 0; i < b; i++)
{
cin >> arr[i];
}
sort(arr, arr + b);
for (int i = 0; i < b; i++)
{
cout << arr[i] << " ";
}
return 0;
}
python:(40分)
整体语法没错,估计是特殊案例,懒得也没法处理了
a, b = map(int, input().split(" "))
arr = input().split(" ")
arr.sort()
for i in arr:
print(f"{i}", end = " ")