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.
#include <bits/stdc++.h>
using namespace std;
long long a,b,i,dem,s;
int main()
{
cin>>a>>b;
dem=0;
s=0;
for (i=a; i<=b; i++)
if (i%2==0)
{
dem++;
s=s+i;
}
cout<<dem<<" "<<s;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a,b,i,dem,s;
int main()
{
cin>>a>>b;
dem=0;
s=0;
for (i=a; i<=b; i++)
if (i%2==0)
{
dem++;
s=s+i;
}
cout<<dem<<" "<<s;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a,b,i,dem,s;
int main()
{
cin>>a>>b;
dem=0;
s=0;
for (i=a; i<=b; i++)
if (i%2==0)
{
dem++;
s=s+i;
}
cout<<dem<<" "<<s;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long x,i,n,t,dem;
int main()
{
cin>>n;
t=0;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0)
{
dem++;
t=t+x;
}
cout<<t<<" "<<dem;
return 0;
}
}
Program bt_3;
Uses crt;
Var Tong, n, i: integer;
Begin
Clrscr;
Writeln(‘nhap n=’);
Readln (n);
Tong:=0;
For i:=1 to n do
If I mod 2 = 0 then Tong:= Tong+i;
Writeln(‘Tong la:’,Tong);
Readln
End.
uses crt;
var a:array[1..200]of integer;
i,n,tbc,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so duong chan la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>0) then write(a[i]:4);
writeln;
tbc:=0;
dem:=0;
for i:=1 to n do
if (-1000<=a[i]) and (a[i]<=1000) then
begin
tbc:=tbc+a[i];
dem:=dem+1;
end;
writeln('Trung binh cong cac phan tu co gia tri trong pham vi tu -1000 den 1000 la: ',tbc/dem:4:2);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[1000];
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
for (i=n; i>=1; i--) cout<<a[i]<<" ";
return 0;
}
Bài 2:
#include <bits/stdc++.h>;
using namespace std;
int main();
{
long m,n;
cout<<"Nhap m="; cin>>m;
cout<<"Nhap n="; cin>>n;
cout<<m*n-2;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a,b,i,dem,s;
int main()
{
cin>>a>>b;
dem=0;
s=0;
for (i=a; i<=b; i++)
if (i%2==0)
{
dem++;
s=s+i;
}
cout<<dem<<" "<<s;
return 0;
}