Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
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;
}
Var a:array[1..100] of integer;
i,s:integer;
Begin
For i:=1 to 100 do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
If a[i] mod 2 <> 0 then s:=s+a[i];
End;
Write('Tong la ',s);
Readln;
End.
#include <bits/stdc++.h>
using namespace std;
long long a[50],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],b[1000],i,n,t,dem;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
dem=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0)
{
dem++;
b[dem]=a[i];
}
for (i=1; i<=dem; i++) cout<<b[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=dem; i++) t+=b[i];
cout<<t;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem1,dem2:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
dem1:=0;
for i:=1 to n do
if (a[i]>a[i-1]) and (a[i]>a[i+1]) then dem1:=dem1+1;
dem2:=0;
for i:=1 to n do
if (a[i]<a[i-1]) and (a[i]<a[i+1]) then dem2:=dem2+1;
writeln(dem1);
writeln(dem2);
readln;
end.
#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;
}