Bài 1:
#include <bits/stdc++.h>
using namespace std;
long long a[50],n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>a[i];
t=t+a[i];
}
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
cout<<t;
return 0;
}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long a[50],n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>a[i];
t=t+a[i];
}
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
for (i=n; i>=1; i--) cout<<a[i]<<" ";
return 0;
}