

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
#include <bits/stdc++.h>
using namespace std;
int main(){
FILE *gh;
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,k; cin >> n >> k;
int a[n];
for(int i=0;i<n;i++) {
cin >> a[i];
if(a[i] < 0) a[i] = abs(a[i]);
else a[i] = k - a[i];
}
cout << *max_element(a,a+n);
return 0;
gh = freopen("ants.inp", "w+", stdout);
gh = freopen("ants.out", "w+", stdout);
fclose(gh);
}
Hãy giúp mọi người biết câu trả lời này thế nào?
![]()
#include <bits/stdc++.h>
using namespace std;
int main(){
freopen("ants.inp", "r", stdin);
freopen("ants.out", "w", stdout);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,k; cin >> n >> k;
int a[n];
for(int i=0;i<n;i++) {
cin >> a[i];
if(a[i] < 0) a[i] = abs(a[i]);
else a[i] = k - a[i];
}
cout << *max_element(a,a+n);
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
![]()
Bảng tin
165
2805
69
thêm có 4 dòng thôi
165
2805
69
nào cần ghi nội dung vào file txt thì tôi sửa lại
165
2805
69
thực ra bỏ txt cũng đc
0
112
0
lỗi thời gian bạn ạ