#include
using namespace std;
int main()
{
int arr[1000] = {};
int n, m;
cin >> n >> m;
int number;
for (int i = 0;i < m;i++)
{
cin >> number;
arr[number -1] += 1;
}
for (int i = 0;i < n;i++)
{
for (int j = 0;j < arr[i];j++)
{
cout << i + 1 << " ";
}
}
}
#include
using namespace std;
#include
int main()
{
int n;
cin >> n;
long number;
listL;
for (int i = 0;i < n;i++)
{
cin >> number;
L.push_back(number);
}
L.sort();
for (list::iterator it = L.begin();it != L.end();it++)
{
cout << *it << " ";
}
system("pause");
return 0;
}
#include
using namespace std;
#include
#include
int main()
{
int n;
cin >> n;
long number;
vectorv;
for (int i = 0;i < n;i++)
{
cin >> number;
v.push_back(number);
}
sort(v.begin(), v.end());
for (vector::iterator it = v.begin();it != v.end();it++)
{
cout << *it << " ";
}
system("pause");
return 0;
}
//超时
#include
using namespace std;
#include
long arr[100000] = {};
int main()
{
int n;
cin >> n;
long number;
long temp;
for (int i = 0;i < n;i++)
{
cin >> number;
arr[i] = number;
}
for (int i = 0;i < n;i++)
{
for (int j = 0;j < n-i-1;j++)
{
if (arr[j] > arr[j + 1])
{
temp = arr[j+1];
arr[j + 1] = arr[j];
arr[j] = temp;
}
}
}
for (int i = 0;i < n;i++)
{
cout << arr[i] << " ";
}
system("pause");
return 0;
}
#include
using namespace std;
#include
long arr[5000000] = {};
int main()
{
int n;
long number;
int flag;
cin >> n;
cin >> flag;
for (int i = 0;i < n;i++)
{
cin >> number;
arr[i] = number;
}
sort(arr, arr + n);
cout << arr[flag] << endl;
system("pause");
return 0;
}
#define _CRT_SECURE_NO_WARNINGS 1
#include
using namespace std;
long arr[5000000] = {};
int quicksort(int left, int right)
{
int mid = arr[left];
while (left < right)
{
while (left < right && mid <= arr[right])
right--;
arr[left] = arr[right];
while (left < right && arr[left] <= mid)
left++;
arr[right] = arr[left];
}
arr[left] = mid;
return left;
}
int find(int left, int right, int k)
{
int temp = quicksort(left, right);
if (temp == k)
{
cout << arr[temp];
}
else if (k - 1 < temp)
{
find(left, temp - 1, k);
}
else
{
find(temp + 1, right, k);
}
return 0;
}
int main()
{
int n, k;
cin >> n >> k;
int number;
for (int i = 0;i < n;i++)
{
scanf("%d", &arr[i]);
}
find(0, n - 1, k);
system("pause");
return 0;
}
#include
using namespace std;
#include
int arr[5000000] = {};
int main()
{
int n, m;
cin >> n >> m;
for (int i = 0;i < n;i++)
{
scanf("%d", &arr[i]);
}
nth_element(arr, arr + m, arr + n);
printf("%d", arr[m]);
system("pause");
return 0;
}
#define _CRT_SECURE_NO_WARNINGS 1
#include
using namespace std;
#include
int main()
{
int n;
cin >> n;
sets;
int num;
for (int i = 0;i < n;i++)
{
scanf("%d", &num);
s.insert(num);
}
cout << s.size() << endl;
for (set::iterator it = s.begin();it != s.end();it++)
{
cout << *it << " ";
}
system("pause");
return 0;
}
#define _CRT_SECURE_NO_WARNINGS 1
#include
#include
using namespace std;
int main()
{
int arr[100] = {};
int n;
cin >> n;
for (int i = 0;i < n;i++)
{
scanf("%d", &arr[i]);
}
sort(arr, arr + n);
int flag = n;
for (int i = 1;i < n;i++)
{
if (arr[i] == arr[i - 1])
{
flag--;
}
}
printf("%d\n", flag);
cout << arr[0] << " ";
for (int i = 1;i < n;i++)
{
if (arr[i] != arr[i - 1])
{
cout << arr[i] << " ";
}
}
system("pause");
return 0;
}
#include
using namespace std;
#include
#include
struct Student
{
int m_Code;
int m_Score1;
int m_Score2;
};
bool mycompare(const Student& s1, const Student& s2)
{
if (s1.m_Score1 == s2.m_Score1)
{
if (s1.m_Score2 == s2.m_Score2)
{
return s1.m_Code < s2.m_Code;
}
return s1.m_Score2 > s2.m_Score2;
}
return s1.m_Score1 > s2.m_Score1;
}
int main()
{
int n, score1, score2, code;
cin >> n;
vectorv;
Student s;
int score;
for (int i = 0;i < n;i++)
{
score1 = 0;
scanf("%d", &score);
score2 = score;
score1 += score;
scanf("%d", &score);
score1 += score;
scanf("%d", &score);
score1 += score;
code = i + 1;
s.m_Code = code;
s.m_Score1 = score1;
s.m_Score2 = score2;
v.push_back(s);
}
sort(v.begin(), v.end(), mycompare);
vector::iterator pos = v.begin();
for (int i = 0;i < 5;i++)
{
cout << (*pos).m_Code << " " << (*pos).m_Score1 << endl;
pos++;
}
system("pause");
return 0;
}
#include
using namespace std;
#include
string str;
int main()
{
int n;
cin >> n;
int result1;
string result2="0";
int code;
int l1, l2;
for (int i = 0;i < n;i++)
{
code = i + 1;
cin >> str;
l1 = str.length();
l2 = result2.length();
if (l1 > l2)
{
result2 = str;
result1 = code;
}
else if (l2 == l1)
{
int start = 0;
while (str[start] == result2[start])
{
start++;
}
if (((int)(str[start])) > ((int)(result2[start])))
{
result2 = str;
result1 = code;
}
}
}
cout << result1 << endl << result2 << endl;
system("pause");
return 0;
}