Viết chương trình nhập vào 1 dãy số gồm n phân tử.Hãy in dãy số đó ra màn hình
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.
1)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] > a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep tang dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
2)
Var array:[1..1000] of integer;
i,n,t:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
For i:=1 to n do
If a[i] < a[i+1] then
Begin
t:=a[i];
a[i]:=a[i+1];
a[i+1]:=t;
End;
Write('Sap xep giam dan ');
For i:=1 to n do write(a[i]:8);
Readln
End.
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,ln;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
ln=a[1];
for (i=1; i<=n; i++) ln=max(ln,a[i]);
cout<<ln;
return 0;
}
Var a:array[1..200] of integer;
i,n,min:integer;
begin
write('Nhap so luong phan tu n = ');readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' = ');readln(a[i]);
min:=a[1];
if a[i] < min then min:=a[i];
end;
write('So nho nhat la ',min);
readln;
end.
Bài này mới đúng nhé!
Var a:array[1..200] of integer;
i,n,min:integer;
begin
write('Nhap so luong phan tu n = ');readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' = ');readln(a[i]);
end;
min:=a[1];
for i:=2 to n do
if a[i] < min then min:=a[i];
write('So nho nhat la ',min);
readln;
end.
Var a:array[1..1000] of integer;
s:longint;
i,n:integer;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i);readln(a[i]);
If a[i] > 0 then s:=s+a[i];
End;
Write('Tong la ',s);
Readln
End.
Program HOC24;
var a: array[1..1000] of integer;
i,k,min: integer;
begin
write('Nhap K: '); readln(k);
for i:=1 to k do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
min:=a[1];
for i:=2 to k do if a[i]<min then min:=a[i];
write('Phan tu nho nhat trong day so la: ',min);
readln
end.
Uses crt;
var i,k,min: longint;
h: array[1..100] of longint;
begin clrscr;
readln(k);
for i:=1 to k do begin
readln(h[i]);
end;
min:=h[1];
for i:=1 to n do begin
if(min>h[i]) then min:=h[i];
end;
writeln(min);
readln;
end.
program In_Day_So_Nguyen;
uses crt;
var
a: array[1..80] of integer;
i: integer;
begin
clrscr;
writeln('Nhap vao day so nguyen: ');
for i := 1 to 80 do
begin
readln(a[i]);
end;
writeln('Day so nguyen ban vua nhap la: ');
for i:=1 to 80 do
begin
write(a[i], ' ');
end;
readln;
end.
program HienThiSoChan;
var
N, i: integer;
A: array[1..50] of integer;
begin
writeln('Nhap so nguyen duong N:');
readln(N);
writeln('Nhap day so A gom ', N, ' phan tu:');
for i := 1 to N do
begin
readln(A[i]);
if A[i] mod 2 = 0 then
begin
writeln('Phan tu thu ', i, ' la so chan: ', A[i]);
end;
end;
readln;
end.
BT1:
Uses crt;
var i,n: integer;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do
read(a[i]); readln;
writeln(a[i]:3);
readln;
end.
BT2:
Uses crt;
var i,n,k: integer;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do
read(a[i]); readln;
for i:=1 to n do begin
if(a[i] mod 2=0) then k:=k+a[i];
end;
writeln(k);
readln;
end.
Bài 2:
#include <bits/stdc++.h>
using namespace std;
string st;
int d;
int main()
{
getline(cin,st);
d=st.length();
cout<<d;
return 0;
}
Bài 1:
Var so,i,n,dem: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 dem:=dem+1;
End;
Write('Co ',dem,' so chan');
Readln;
End.
Bài 2:
Var st:string;
Begin
Write('Nhap vao xau ki tu ');readln(st);
Write(' Xau vua nhap co do dai la ',length(st));
Readln;
End.
uses crt;
var a:array[1..100]of integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
readln;
end.