Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
`*` Note: Đây là kiểu nhập không giới hạn. Vì vậy muốn chạy được code bạn cần phải sử dụng file theo yêu cầu đề bài.
$\texttt{C++}$
#include <bits/stdc++.h>
using namespace std;
int a[1000005], n = 0;
int main()
{
freopen("mang.inp", "r", stdin);
freopen("mang.out", "w", stdout);
while (cin >> a[n])
{
n++;
}
cout << n << '\n';
for (int i = 0; i < n; i++)
{
cout << a[i] << " ";
}
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> a;
int main() {
freopen("mang.inp","r",stdin);
freopen("mang.out","w",stdout);
int x;
while (cin >> x) {
a.push_back(x);
}
sort(a.begin(), a.end());
cout << a.size() << endl;
for (int i:a) cout << i << " ";
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Sự kiện