1.viết chương trình nhập vào số thực a và b .hãy in ra màn hình kết quả của \(\frac{a^2+b^2}{2}\)
2.viết chương trình tính quãng đường của xe oto đi được trong khoảng thời gian t giờ và có vận tốc V km/h
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.
2:
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
cout<<a%b<<endl;
cout<<a/b;
return 0;
}
uses crt;
var a,b:real;
begin
clrscr;
readln(a,b);
writeln(a+b:4:1);
readln;
end.
program b1;
uses crt;
var a,b,s:real;
begin
clrscr;
writeln('Nhap hai so a va b: ');
readln(a,b);
s:=a+b;
write('Tong cua hai so a va b la: ',s:1:1);
readln;
end.
P/S: phần lưu lẫn đặt tên người dùng nào cũng đều làm được.
+ Chọn Save as ở phần File phía góc trái trên cùng rồi đặt tên.
Cách khác(Dùng bằng C++)
#include <bits/stdc++.h>
using namespace std;
double a,b;
int main()
{
cin>>a>>b;
cout<<"Tong la:"<<fixed<<setprecision(2)<<a+b<<endl;
cout<<"Tich la:"<<fixed<<setprecision(2)<<a*b;
return 0;
}
Bài 3:
#include <bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
cin>>a>>b;
cout<<a%b;
cout<<a/b;
return 0;
}
Caua1:
program caumot;
begin
writeln('lop 8A chao ban!');
end.
Câu 2:
program cauhai;
int a,b,c :real;
begin
write('a='); readln(a);
write('b='); readln(b);
c= a+b;
write('Tong hai so a b la:',c);
end.
2:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string st;
int a;
cin>>st;
cin>>a;
cout<<"Xin chao "<<st<<endl;
cout<<"Nam nay "<<st<<" "<<2021-a<<" tuoi";
return 0;
}
Câu 1:
#include <bits/stdc++.h>
using namespace std;
double a,b,c;
int main()
{
cin>>a>>b>>c;
cout<<fixed<<setprecision(2)<<(a+b+c)/3;
return 0;
}
Bài 2:
#include <bits/stdc++.h>
using namespace std;
string st;
int d;
int main()
{
getline(cin,st);
d=st.length();
cout<<d;
return 0;
}
Bài 1:
Var so,i,n,dem:integer;
Begin
Write('Nhap so luong so n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i);readln(so);
If so mod 2 = 0 then dem:=dem+1;
End;
Write('Co ',dem,' so chan');
Readln;
End.
Bài 2:
Var st:string;
Begin
Write('Nhap vao xau ki tu ');readln(st);
Write(' Xau vua nhap co do dai la ',length(st));
Readln;
End.
1:
uses crt;
var a,b,bt:real;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
bt:=(sqr(a)+sqr(b))/2;
writeln('bieu thuc=',bt:4:2);
readln;
end.
2:
uses crt;
var s,v,t:integer;
begin
clrscr;
write('nhap thoi gian xe chay:'); readln(t);
write('nhap van toc cua xe:'); readln(v);
s:=v*t;
writeln('quang duong xe chay duoc la: ',s:4:2);
readln;
end.