viết chương trình tìm số lớn nhất trong ba số được nhập từ bàn phím x,y,z kiểu nguyên trong đó có sử dụng chương trình con có hai tham số hình thức a,b kiểu nguyên
Câu 1. Viết chương trình thực hiện yêu cầu sau: a, Sử dụng mảng để nhập từ bàn phím các phân tử của 1 dãy số có kiểu số nguyên? Biết độ dài của dãy số được nhập từ bàn phím . b, In ra màn hình các số vừa nhập của dãy số đó. c, In ra màn hình số lớn nhất trong dãy số. Mn giúp mik với mik cần gấp.mik c.ơn
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.
Viết chương trình tìm giá trị lớn nhất trong 10 phần tử kiểu số nguyên từ bàn phím (Sử dụng biến mảng)
Câu 1 viết chương trình tính giá trị biểu thức với x,y là các số nguyên dc nhập từ bàn phím. In kết quả ra màn hình Caau2 viết chương trình vào 3 số nguyên a,b,c.In ra màn hình số lớn nhất trong 3 số đó
Câu 2:
Program nii;
Uses crt;
Var a,b,c,A:integer;
Begin
Write ('nhap a');
Readln (a);
Write ('nhap b');
Readln (b);
Write ('nhap c');
Readln (c);
A:=a;
If A<b then A:=b;
If A<c then A:=c;
Write ('Ket qua',A);
Readln;
End.
Câu 1
Program ntg;
Uses crt;
Var A,x,y:integer;
Begin
Write ('nhap x');
Readln (x);
Write ('nhap y');
Readln ('y');
A:=x+y;
Write ('Ket qua',A);
Readln;
End.
Câu 2:
uses crt;
var a,b,c,max:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
max:=a;
if max<b then max:=b;
if max<c then max:=c;
writeln('So lon nhat trong 3 so la: ',max);
readln;
end.
Sử dụng chương trình con tìm số nhỏ nhất của 2 số. Viết chương trình sử dụng chương trình con trên tìm và đưa ra màn hình giá trị nhỏ nhất của mảng một chiều chứa n số nguyên nhập từ bàn phím. Giúp em với mọi người ❤️
uses crt;
var a:array[1..100]of integer;
min,n,i:integer;
{----------------chuong-trinh-con-------------------}
function nn(x,y:integer):integer;
begin
if x<y then nn:=x
else nn:=y;
end;
{-----------------chuong-trinh-chinh-----------------}
begin
clrscr;
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=nn(a[1],a[2]);
for i:=3 to n do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
1. Viết chương trình tạo tệp baitap.txt trong đó dòng đầu tiên n là số lượng các số nguyên, dòng thứ 2 là n số nguyên cách nhau 2 kí tự trắng được nhập từ bàn phím (N<=100)
2.Viết chương trình tìm số nguyên lớn nhất trong n số nguyên đã có trong tệp baitap.txt và ghi kết quả vào tệp solonnhat.txt
Mong mọi người giúp mình giải sớm =(((
Câu 2:
uses crt;
var a,b:integer;
{-----------------chuong-trinh-con-------------------}
function ucln(x,y:integer):integer;
var i,uc:integer;
begin
if x<y then
begin
uc:=1;
for i:=1 to x do
if (x mod i=0) and (y mod i=0) then
begin
if uc<i then uc:=i;
end;
end
else begin
uc:=1;
for i:=1 to y do
if (x mod i=0) and (y mod i=0) then
begin
if uc<i then uc:=i;
end;
end;
ucln:=uc;
end;
{--------------------------chuong-trinh-chinh------------------------}
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
writeln(a,'/',b,'=',a div ucln(a,b),'/',b div ucln(a,b));
readln;
end.
Câu 1:
const fi='songuyen.inp'
fo='tong.out'
var f1,f2:text;
a:array[1..100]of integer;
i,n,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eoln(f1) do
begin
n:=n+1;
read(f1,a[n]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(f2,t);
close(f1);
close(f2);
end.
Viết chương trình nhập vào bàn phím mảng 1 chiều A gồm N(N<=200) phần tử nguyên .Tính và viết ra màn hình tổng các số âm có trong mảng A (chương trình sử dụng chương trình con kiểm tra số nguyên âm của số m để viết)
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x<0) t+=x;
}
cout<<t;
return 0;
}
1.Xác định bài toán và mô tả thuật toán tìm số lớn nhất trong 3 số nguyên x,y,z được nhập vào từ bàn phím.
2. Viết chương trình nhập từ bàn phím số nguyên n (|n| <_ 10^9o). KIểm tra n có phải là sô snguyeen dương và chia hết cho 5.
XIN MỌI NGƯỜI GIÚP MÌNH VỚI Ạ! MÌNH CÁM ƠN
Câu 2:
#include <bits/stdc++.h>
using namespace std;
long long n;
int main()
{
cin>>n;
if (n>0 && n%5==0) cout<<"Phai";
else cout<<"Khong phai";
}
C1.Viết chương trình tính tổng hai số A và B với A, B là 2 số được nhập từ bàn phím C2. Viết Chương trình nhập vào ba số nguyên a, b, c. tính a+b-c. C3.Viết Chương trình tính hiệu a - b với a,b là hai số nguyên nhập từ bàn phím. C4.Chương trình nhập vào 3 số x, y, z. Tính (x+y)*z Giúp em với ạ em cảm ơn nhiều lắm ạ
Câu 1:
uses crt;
var a,b:integer;
begin
clrscr;
readln(a,b);
write(a+b);
readln;
end.
Câu 2:
uses crt;
var a,b,c:integer;
begin
clrscr;
readln(a,b,c);
writeln(a+b-c);
readln;
end.
Câu 3:
uses crt;
var a,b:integer;
begin
clrscr;
readln(a,b);
writeln(a-b);
readln;
end.
Câu 4:
uses crt;
var x,y,z:integer;
begin
clrscr;
readln(x,y,z);
writeln((x+y)*z);
readln;
end.
5. Viết chương trình a. Viết chương trình nhập và in ra 1 mảng gôm 40 phần tử kiểu số nguyên b. Viết chương trình nhập vào 1 mảng n số thực và in ra mảng đó ( với n là sô nguyên được nhập từ bàn phím và 0