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.
a:
#include <bits/stdc++.h>
using namespace std;
double a[1000];
int n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
return 0;
}
b:
#include <bits/stdc++.h>
using namespace std;
long long a[50],n,i,t;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
t=0;
for (i=1; i<=n; i++) t+=a[i];
cout<<t;
return 0;
}
bạn có thể nào làm cho mình phần b làm theo kiểu lớp 8 đc không chứ nhìn như này mik ko hiểu
uses crt;
var toan,ly,hoa,van,anh,dtb:real;
begin
clrscr;
write('Nhap diem Toan:'); readln(toan);
write('Nhap diem Ly:'); readln(ly);
write('Nhap diem Hoa:'); readln(hoa);
write('Nhap diem Van:'); readln(van);
write('Nhap diem Anh:'); readln(anh);
dtb:=(toan+ly+hoa+van+anh)/5;
if dtb>=8 then writeln('Gioi');
if (6,5<=dtb) and (dtb<8) then writeln('Kha');
if (5<=dtb) and (dtb<6,5) then writeln('Trung binh');
if dtb<5 then writeln('Yeu');
readln;
end.
Đây là code Pascal để nhập và in điểm kiểm tra học kì môn tin cho N của từng học sinh:
program DiemKT;
var
N, i: integer;
diem: array1..100 of integer;
begin
write('Nhap so hoc sinh: ');
readln(N);
for i := 1 to N do
begin
write('Nhap diem kiem tra hoc ki cua hoc sinh thu ', i, ': ');
readln(diemi);
end;
writeln('Diem kiem tra hoc ki cua ', N, ' hoc sinh la:');
for i := 1 to N do
writeln('Hoc sinh thu ', i, ': ', diemi);
end.
uses crt;
var a:array[1..20]of real;
t,tb,ln,nn:real;
i,n:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t:4:2);
writeln(t/n:4:2);
nn:=a[1];
ln:=a[1];
for i:=1 to n do
begin
if nn>a[i] then nn:=a[i];
if ln<a[i] then ln:=a[i];
end;
writeln(nn);
writeln(ln);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
double a,b,c,tb;
int main()
{
cin>>a>>b>>c;
tb=((a+b)*2+c)/5;
if (tb>=9) cout<<"Gioi";
else if ((tb>=7) and (tb<9)) cout<<"Kha";
else if ((tb>=5) and (tb<7)) cout<<"Trung binh";
else cout<<"Yeu";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
double a,b,c,tb;
int main()
{
cin>>a>>b>>c;
tb=((a+b)*2+c)/5;
if (tb>=9) cout<<"Gioi";
else if ((tb>=7) and (tb<9)) cout<<"Kha";
else if ((tb>=5) and (tb<7)) cout<<"Trung binh";
else cout<<"Yeu";
return 0;
}
Câu 6:
uses crt;
var a:integer;
begin
clrscr;
write('Nhap a='); readln(a);
if a mod 2=0 then writeln(a,' la so chan')
else writeln(a,' la so le');
readln;
end.
Câu 7:
uses crt;
var a,b:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
if a>b then writeln(a-b)
else writeln(b-a);
readln;
end.
Câu 8:
uses crt;
var a,b,c,ln:integer;
begin
clrscr;
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
write('Nhap c='); readln(c);
ln:=a;
if ln<b then ln:=b;
if ln<c then ln:=c;
writeln(ln);
readln;
end.
Câu 10:
uses crt;
var toan,ly,hoa,dtb:real;
begin
clrscr;
write('Nhap diem Toan:'); readln(toan);
write('Nhap diem Ly:'); readln(ly);
write('Nhap diem Hoa:'); readln(hoa);
dtb:=(toan*2+ly+hoa)/4;
if dtb<5 then writeln('Yeu');
if (5<=dtb) and (dtb<8) then writeln('Kha');
if dtb>=8 then
begin
if (toan=10) and (hoa>7) and (ly>7) then writeln('Gioi va nhan hoc bong')
else writeln('Gioi va khong nhan hoc bong');
end;
readln;
end.
Bạn ơi chỗ câu 8 ln:=a thì ln là gì vậy bạn?