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.
uses crt;
var a:array[1..100]of integer;
i,n,t,kt,j:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do
if a[i] mod 2<>0 then t:=t+a[i];
writeln(t);
for i:=1 to n do
if trunc(sqrt(a[i]))=sqrt(a[i]) then write(a[i]:4);
writeln;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then kt:=1;
if kt=0 then write(a[i]:4);
end;
readln;
end.
Bài 1:
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
for i:=1 to n do
s:=s+1/(2*i+1);
writeln(s:4:2);
readln;
end.
Var s,n,i,so:integer;
Begin
Write('Nhap so luong so n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i)readln(so);
If so mod 2 = 0 then s:=s+so;
End;
Write('Tong cac so chan la ',s);
Readln;
End.
Var a:array:[1..1000] of integer;
i,n,max:integer;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
End;
Write('Cac diem vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
max:=a[1];
For i:=2 to n do
if a[i] > max then max:=a[i];
write('So lon nhat la ',max);
Readln
End.
uses crt;
var a:array[1..100]of integer;
i,n:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
if a[i] mod 2<>0 then write(a[i]:4);
readln;
end.
uses crt;
var i,n: integer;
a: array[1..10000] of integer;
begin
writeln('nhap so nguyen n: '); readln(n);
for i:=1 to n do
begin
writeln('A[',i,']'); readln(a[i]);
if i mod 2 <>0 then writeln(i);
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++)
cin>>a[i];
cout<<"Cac so le la: "<<endl;
for (i=1; i<=n; i++) if (a[i]%2!=0) cout<<a[i]<<" ";
cout<<endl;
cout<<"Cac so chan la: "<<endl;
for (i=1; i<=n; i++) if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}
n = int(input("Nhập vào giá trị của n: "))
even_count = 0
odd_count = 0
for i in range(1, n+1):
if i % 2 == 0:
even_count += 1
else:
odd_count += 1
print("Số chẵn trong dãy là:", even_count)
print("Số lẻ trong dãy là:", odd_count)
uses crt;
var a:array[1..100]of integer;
i,n,dem,kt,j:integer;
begin
clrscr;
readln(n);
for i:=1 to n do write(i:4);
writeln;
for i:=2 to n do
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then write(i:4);
end;
readln;
end.
Var a:array[1..100] of integer;
i,n:integer;
s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
s:=s+a[i];
End;
Write('Cac phan tu vua nhap la ');
For i:=1 to n do
Write(a[i]:8);
Writeln;
Write('Tong cua chung la ',s);
Readln
End.
#include <bits/stdc++.h>
using namespace std;
int n,kt,t;
int main()
{
cin>>n;
int t=0;
for (int i=1; i<=n; i++)
if (i%2==1) cout<<i<<" ";
cout<<endl;
for (int i=2; i<=n; i++)
{
kt=0;
for (int j=2; j*j<=i; j++)
if (i%j==0) kt=1;
if (kt==0) cout<<i<<" ";
}
return 0;
}