viet chuong trinh nhap 1 so nguyen khac khong tu ban phim,viet ra man hinh cac so tu nhien chan
viet chuong trinh nhap vao mang so nguyen a(toi da 100 phan tu) tu ban phim in len man hinh cac phan tu chia het cho K (khong duoc nhap vao tu ban phim khi chay chuong trinh) trong mang
viet chuong trinh nhap vao cac so nguyen tu ban phim va tinh tong cua chung.Chuong trinh dung lai khi tong lon hon hoac bang a(a la so nhap tu ban phim)va thong bao tong do ra man hinh(Free Pascal)
Giup minh voi
Viet chuong trinh nhap n so nguyen tu ban phim (do dai day so nhap tu ban phim);
a.In ra cac so nguyen duong
b.In ra man hinh cac so ngto trong day so vua nhap
Mn giup ban mik vs giai giup mik bai nay nha
Cam on aj
uses crt;
var a:array[1..100]of integer;
n,i,kt,j: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 nguyen duong la: ');
for i:=1 to n do
if a[i]>0 then write(a[i]:4);
writeln;
writeln('Cac so nguyen to la: ');
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then write(a[i]:4);
end;
readln;
end.
viet chuong trinh nhap vao so mguyen n va day so gom n la so nguyen tu ban phim in ra man hinh so lon nhat trong day so nguyen vua nhap
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.
viet chuong trinh tinh tong cac so co gia tri khac nhau trong day n so nguyen (1<n<1000) duoc nhap tu ban phim
viet CT nhap 1 so nguyen n khac 0 tu ban phim,viet ra man hinh tat ca cac uoc cua n
uses crt;
var n,i:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n>0;
write('Cac uoc cua ',n,' la: ');
for i:=1 to n do
if n mod i=0 then write(i:4);
readln;
end.
Program HOC24;
var i,n: integer;
begin
write('Nhap n : '); readln(n);
for i:=1 to n do
if n mod i=0 then write(i,' ');
readln
end.
viet chuong trinh nhap vao tu ban phim so nguyen duong N , tinh tong gia tri chia het cho 3 trong pham vi tu 1 den N , sau do in ra man hinh
uses crt;
var n,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 3=0 then t:=t+i;
writeln(t);
readln;
end.
1) Viet chuong trinh nhap 2 so thuc tu ban phim. Doi gia tri 2 so do va in ket qua ra man hinh
#include <bits/stdc++.h>
using namespace std;
double a,b;
int main()
{
cin>>a>>b;
cout<<"a truoc khi doi la:"<<fixed<<setprecision(2)<<a<<endl;
cout<<"b truoc khi doi la:"<<fixed<<setprecision(2)<<b<<endl;
swap(a,b);
cout<<"a sau khi doi la:"<<fixed<<setprecision(2)<<a<<endl;
cout<<"b sau khi doi la:"<<fixed<<setprecision(2)<<b;
return 0;
}
trinh viet chuong nhap vao 1 mang 1 chieu gom n phan tu ( voi n duoc nhap vao tu ban phim ). Hay thuc hien cac cong viec sau:
-Nhap/xuar mang
- Dem co bao nhieu phan tu la so chan trong mang
-Kiem tra xem mang co phai la mang le hay khong ? ( tat ca cac phan tu mang la so le )
Bạn ơi phải viết bằng ngôn ngữ lập trình gì vậy.