viet phuong trinh tao tep so.txt gom n so nguyen duong chan
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.
Lời giải :
program hotrotinhoc ;
var a: array[1..32000] of integer ;
i,n,max : integer ;
begin
write('Nhap n='); readln(n);
writeln('Nhap gia tri cua cac phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:= 1 to n do if max<a[i] then max:=a[i];
write('So lon nhat la:',max');
readln
end.
var s,i,n:integer;
begin
Write('n = ');
While (n > 100) and (n < 1) then
Begin
write('Nhap sai, nhap lai ');readln(n);
End;
for i:=1 to n do
s:=s+i;
write('tong la: ',s);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
string s1;
int d,i;
int main()
{
getline(cin,s1);
d=s1.length();
for (i=0; i<=d-1; i++)
if ((s1[i]>=48) and (s1[i]<=57)) cout<<s1[i];
return 0;
}
program so_tu_nhien_chan;
uses crt;
var n,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
write('Cac so chan nho hon hoac bang ',n,' la: ');
for i:=2 to n do
if i mod 2=0 then write(i:4,' ;');
readln;
end.
uses crt;
var a,b:array[1..100]of integer;
n,i,dem,max,tam,j:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=100);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chia het cho 4 la: ');
for i:=1 to n do
if a[i] mod 4=0 then write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i] mod 7=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
max:=b[1];
for i:=1 to dem do
if max<b[i] then max:=b[i];
writeln('So lon nhat chia het cho 7 la: ',max);
writeln('Cac chi so cua no trong day A la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
writeln;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('Day so sau khi sap xep giam dan la: ');
for i:=1 to n do
write(a[i]:4);
readln;
end.
1,2345678
2,4357656
3,3456543
4,4963476
5,8632549
đúng thì k nha
uses crt;
var n,i:integer;
a: array[1..100] of integer;
f: text;
const fi = 'so.txt';
begin
clrscr;
write('Nhap so phan tu: ');readln(n);
assign(f,fi);
rewrite(f);
for i:= 1 to n do
begin
write('Nhap so thu ',i,': ');
readln(a[i]);
if a[i] mod 2 = 0 then
writeln(f,a[i]);
end;
close(f);
readln
end.
uses crt;
const fi='tepso.txt';
var n,i:integer;
f1:text;
begin
clrscr;
assign(f1,fi); rewrite(f1);
write('Nhap n='); readln(n);
for i:=0 to 2*n-2 do
if i mod 2=0 then write(f1,i:4);
close(f1);
readln;
end.