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,d,j,kt:integer;
st:string;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
begin
str(a[i],st);
d:=length(st);
kt:=0;
for j:=1 to d do
if st[j]<>st[d-j+1] then kt:=1;
if kt=0 then write(st:4);
end;
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++) t+=a[i];
cout<<t;
return 0;
}
Bài 1
Var a:array:[1..99] of integer;
i,n:integer;
s:longint;
Begin
Repeat
Write('n = ');readln(n);
Until (n > 0) and (n < 100);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
if a[i] mod 2 = 0 then s:=s+a[i];
End;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
write('Tong cac so chan la ',s);
Readln
End.
Bài 2
Var a:array:[1..99] of integer;
i,n:integer;
s:longint;
Begin
Repeat
Write('n = ');readln(n);
Until (n > 0) and (n < 100);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
if a[i] mod 2 <> 0 then s:=s+a[i];
End;
Write('Cac so vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
write('Tong cac so le la ',s);
Readln
End.
Bài 1:program sothuc;
uses crt;
var a:array[1..10] of real;s,i,j:real;
begin
s:=0;
for i:=1 to 10 do begin writeln('A[',i,']=');readln(a[i]); end;
for i:=1 to 10 do if a[i]<0 then
for j:=1 to 10 do
begin a[j]:=sqr(a[i]); s:=s+a[j]; end;
writeln('tong binh phuong cac so am la: ',s:2:2); readln;
end. (Khi nào mình kiểm tra chạy lại trên phần mềm rồi sửa lại nếu sai nhé)
Bài 2:
program soduong;
uses crt;
var a:array[1..100] of integer;s,i,n:integer;
begin
clrscr;
writeln('nhap do dai cua day');readln(n);
for i:=1 to n do begin
writeln('a[',i,']=');readln(a[i]);
if a[i] mod 2 = 0 then s:=s+a[i] end;
writeln('tong so duong trong day la',s:2:0);readln
end.
Bài 3: các số dương mà là số lẻ là sao thế bạn????
Bài 1:
uses crt;
var n,i,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
i:=1;
while i<=n do
begin
s:=s+i;
inc(i);
end;
writeln('Tong cac so trong khoang tu 1 den ',n,' la: ',s);
readln;
end.
Bài 2:
uses crt;
var n,i,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
s:=0;
i:=1;
while i<=n do
begin
s:=s+i;
i:=i+2;
end;
writeln('Tong cac so le trong khoang tu 1 den ',n,' la: ',s);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
s:=1;
for i:=1 to n do
s:=s*a[i];
writeln('Tich la: ',s:0:0);
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Trung binh la: ',t/n:4:2);
readln;
end.
Program HOC24;
var n,d,i: integer;
B: array[1..100] of integer;
t: longint;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
d:=0; t:=0;
for i:=1 to n do
if b[i]>0 then
begin
d:=d+1;
t:=t+b[i];
end;
writeln('Tong cac so duong trong day so la: ',t);
write('Co ',d,' so duong trong day');
readln
end.
uses crt;
var b:array[1..100] of longint;
n,i,d,s:longint;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']: '); readln(b[i]);
if b[i]>0 then begin
inc(d);
inc(s,b[i]);
end;
end;
writeln('Tong cac so duong: ',s);
writeln('Co ',d,' so duong');
readln;
end.
uses crt;
var n, i, j, dem: longint; {Bạn có thể thay longint thành integer nha}
A:array[1..1000] of longint;
begin
clrscr;
Write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(A[i]);
end;
Write('Cac so nguyen to co trong mang la: ');
for i:=1 to n do
begin
dem:=0;
for j:=2 to A[i]/2 do
if A[i] mod j=0 then dem:=dem+1;
if dem=0 then write(A[i],'; ');
end;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
ví dụ:
uses crt;
var a:array[1..100]of integer;
i,n,d,j,kt:integer;
st:string;
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
begin
str(a[i],st);
d:=length(st);
kt:=0;
for j:=1 to d do
if st[j]<>st[d-j+1] then kt:=1;
if kt=0 then write(st:4);
end;
readln;
end.