Hãy cho biết kiểu dữ liệu của các biến cần khai báo dùng để viết chương trình giải bài toán tính điểm trung bình của môn Toán(T), môn Văn(V) và môn Anh(A).(T,V,A được nhập từ bàn phím).
Một chương trình máy tính được viết để nhập điểm của ba môn Toán, Văn, Anh và in ra điểm trung bình của ba môn học đó. Hãy cho biết chương trình đó xử lí những dữ liệu nào và những dữ liệu đó phải có kiểu dữ liệu gì?
Xử lí những dữ liệu là điểm ba môn Toán,Văn, Anh
Những kiểu dữ liệu đó phải có kiểu số thực
Viết chương trình sử dụng chương trình con để tính điểm trung bình 3 môn Toán Văn Anh của năm bạn học sinh biết điểm từng bạn được nhập từ bàn phím
uses crt;
var a,b,c,tb:array[1..100]of real;
i,n:integer;
begin
clrscr;
n:=5;
for i:=1 to n do
begin
readln(a[i],b[i],c[i]);
end;
for i:=1 to n do
tb[i]:=(a[i]+b[i]+c[i])/3;
for i:=1 to n do
writeln('Diem trung binh cua ban thu ',i,' la: ',tb[i]:4:2);
readln;
end.
CÓ BẠN NÀO GIỎI MÔN NÀY K Ạ GIÚP MIK VỚI MIK CẦN GẤP LẮM Ạ Cho hai biến a,b, có kiểu dữ liệu số nguyên. Em hãy viết chương trình Pascal thực hiện các yêu cầu sau: a) Khai báo hai biến a,b. b) Nhập giá trị của hai biến a,b từ bàn phím. c) In kết quả tổng của a,b ra màn hình.
Program tinh_tong;
uses crt;
var a,b:Integer;
begin
Write('Nhap gia tri a: ');
Readln(a);
Write('Nhap gia tri b: ');
Readln(b);
Writeln('Tong: ',a+b);
Readln();
end.
viết chương trình nhập vào từ bàn phím mảng một chiều dùng để lưu trữ điểm trung bình của các môn học hãy đưa ra màng hình như sau
A nhập mảng
B in mảng
C tính điểm trung bình môn
D nếu điểm trung bình >=5 thì thồn báo được lên lớp ngược lại thì thông báo thi lại
uses crt;
var a:array[1..14]of real;
i,n:integer;
t:real;
begin
clrscr;
write('Nhap so mon hoc='); readln(n);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until (0<=a[i]) and (a[i]<=10);
end;
for i:=1 to n do
write(a[i]:4:2,' ');
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Diem trung binh mon la: ',t/n:4:2);
if t>=5 then writeln('Duoc len lop')
else writeln('Thi lai');
readln;
end.
Hãy cho biết kiểu dữ liệu của các biến cần khai báo dùng để viết chương trình để giải bài toán dưới đây:
a) Tìm diện tích S của hình tam giác với độ dài một cạnh a và chiều cao tương ứng h (a và h là các số tự nhiên được nhập từ bàn phím).
b) Tính kết quả C của phép chia lấy phần nguyên và kết quả d của phép chia lấy phần dư của 2 số nguyên a và b.
Các kiểu dữ liệu của các biến cần khai báo :
a) a, h : integer
S : real
Giải thích lý do S không thể là integer : a , h có thể là số nguyên, S=a*h/2 ; a * h chưa chắc là 1 số chẵn nên chia 2 có thể ra số thập phân.
b) c, d : integer ( phần nguyên và phần dư đều là số nguyên )
Viết chương trình nhập vào điểm 2 môn Toán, Văn từ bàn phím. Điểm Anh văn được gán bằng 8.0 điểm. Sau đó tính tổng điểm, điểm trung bình cộng 3 môn học trên và đưa kết quả ra màn hình. (Điểm trung bình cộng lấy 1 số thập phân.) lẹ cho mình nha cảm mưn mn.
Câu 1: viết chương trình tính (a+b)/(a-b) nhập từ bàn phím
câu 2 viết chương trình tính a*a+ b*b+ c*c nhạp từ bàn phím
Câu 3 viết chương tính x*y/z với x,y,z nhập từ bàn phím
Câu 4: Viết chương trình nhập vào 3 môn văn toán anh tính trung bình cộng
Câu 5: viết chương trình nhập vào 4 số a,b,c,d sau đó tính trung bình cộng của 4 số đó
Câu 6: Viết chương trình tính diện tích hình tam giác
Câu 7: tính diện tích chu vi hình tròn (chỉ với ạ cảm ơn mọi người)
Câu 1:
Uses crt;
Var a,b:real;
Begin
Clrscr;
Readln(a);
Readln(b);
Writeln((a+b)/(a-b));
Readln
End.
Câu 2:
Uses crt;
Var a,b,c:real;
Begin
Clrscr;
Readln(a);
Readln(b);
Readln(c);
Writeln(a*a+b*b+c*c);
Readln
End.
Câu 5:
Uses crt;
Var a,b,c,d:real;
Begin
Clrscr;
Readln(a);
Readln(b);
Readln(c);
Readln(d);
Writeln((a+b+c+d)/4);
Readln
End.
Viết chương trình nhập từ bàn phím điểm môn tiếng Anh và môn Vật lý của n học sinh tính trung bình cộng môn tiếng Anh và môn lý của cả lớp
program TinhTBCMon;
var
n, i: integer;
diemAnh, diemVL, tongDiemAnh, tongDiemVL: real;
begin
tongDiemAnh := 0;
tongDiemVL := 0;
write('Nhap so hoc sinh: ');
readln(n);
for i := 1 to n do
begin
write('Nhap diem Tieng Anh cua hoc sinh ', i, ': ');
readln(diemAnh);
tongDiemAnh := tongDiemAnh + diemAnh;
write('Nhap diem Vat ly cua hoc sinh ', i, ': ');
readln(diemVL);
tongDiemVL := tongDiemVL + diemVL;
end;
writeln('Diem trung binh mon Tieng Anh cua lop la: ', tongDiemAnh/n:0:2);
writeln('Diem trung binh mon Vat ly cua lop la: ', tongDiemVL/n:0:2);
readln;
end.
Viết chương trình nhập vào điểm các môn toán , tin, anh. Tính và thông báo ra màn hình điểm trung bình 3 môn và dựa vào điểm trung bình hãy xếp loại cho học sinh đó ( Biết rằng học sinh giỏi nếu điểm tất cả các môn đều trên 6,5 và điểm trung bình trên 8, học sinh khá nếu điểm các môn trên 5 và điểm trung bình trên 6,5, còn lại là học sinh trung bình) (C++)
#include <bits/stdc++.h>
using namespace std;
double a,b,c,tb;
int main()
{
cin>>a>>b>>c;
tb=(a+b+c)/3;
cout<<fixed<<setprecision(1)<<tb<<endl;
if (tb>=8) cout<<"Gioi";
else if ((6.5<=tb) and (tb<8)) cout<<"Kha";
else if ((5<=tb) and (tb<=6.5)) cout<<"Trung Binh";
else cout<<"Chua dat";
return 0;
}
var t,dt,a,tb: real;
begin
write('Nhap diem mon Toan: '); readln(t);
write('nhap diem mon Tin: '); readln(dt);
write('Nhap diem mon Anh: '); readln(a);
if (a<=0) or (a>=10) or (t<=0) or (t>=10) or (dt<=0) or (dt>=10) then
repeat
writeln('Khong hop le, nhap lai: ');
write('Nhap diem mon Toan: '); readln(t);
write('nhap diem mon Tin: '); readln(dt);
write('Nhap diem mon Anh: '); readln(a);
until (a>=0) and (a<=10) and (t>=0) and (t<=10) and (dt>=0) and (dt<=10);
tb:=(t+dt+a)/3;
writeln('Diem trung binh: ',tb:2:1);
if (dt>=6.5) and (t>=6.5) and (a>=6.5) and (tb>=8) then writeln('Gioi') else
if (dt>=5) and (t>=5) and (a>=5) and (tb>=6.5) then writeln('Kha') else writeln('Trung binh');
end.
uses crt;
var toan,tin,anh,tb:real;
kt:integer;
begin
clrscr;
repeat
write('Nhap diem Toan:'); readln(toan);
write('Nhap diem Tin:'); readln(tin);
write('Nhap diem Anh:'); readln(anh);
until (0<=toan) and (toan<=10) and (0<=tin) and (tin<=10) and (0<=anh) and (anh<=10);
tb:=(toan+tin+anh)/3;
writeln('Diem trung binh cua 3 mon la: ',tb:4:2);
kt:=0;
if (tb>=8) and (toan>=6.5) and (tin>=6.5) and (anh>=6.5) then kt:=1;
if (6.5<=tb) and (tb<8) and (5<=toan) and (toan<6.5) and (5<=tin) and (tin<6.5) and (5<=anh) and (anh<6.5) then kt:=2;
if kt=0 then writeln('Hoc sinh trung binh');
if kt=1 then writeln('Hoc sinh gioi');
if kt=2 then writeln('Hoc sinh kha');
readln;
end.