Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
#include <iostream>
#define f(i,a,b) for(int i=a; i<=b; i++)
using namespace std;
int main() {
freopen("BAI2.INP","r",stdin);
freopen("BAI2.OUT","w",stdout);
int n;
cin >> n;
double a[n+1],b[n+1];
f(i,1,n) cin >> a[i];
f(i,1,n) cin >> b[i];
int M=1,N=1;
f(i,1,2*n) {
if (i%2) {
cout << a[M];
M++;
} else {
cout << b[N];
N++;
} cout << " ";
}
}
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 n;
double a[1000005], b[1000005];
int main()
{
freopen("BAI12.inp", "r", stdin);
freopen("BAI12.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
for (int i = 1; i <= n; i++)
{
cin >> b[i];
}
int j = 1, k = 1;
for (int i = 1; i <= 2 * n; i++)
{
if (i % 2 != 0)
{
cout << a[j++] << " ";
}
else
{
cout << b[k++] << " ";
}
}
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Sự kiện