Viết chương trình nhập vào tổng số giây. Hãy chuyển đổi và viết ra số thời gian dưới dạng giờ:phút:giây
Bài 6: Cho một số nguyên là khoảng thời gian diễn ra của một sự kiện (tính bằng giây). Hãy biểu diễn thời gian đó dưới dạng “hh:mm:ss” (giờ:phút:giây)
Bài 5 : Có một số tiền N và các tờ tiền mệnh giá 100, 50, 20, 10, 5, 2, 1. Hãy đổi N thành các tờ tiền sao cho tổng số tờ giấy bạc cần dùng là ít nhất.
Ngôn ngữ lập trình C#
Bài 6:
#include <bits/stdc++.h>
using namespace std;
int main () {
int n;
cin >> n;
int p=n/60;
int s=n%60;
if (p<60) {
if (p<10) {
if (s<10) cout <<"00:0" << p << ":0" << s; else cout <<"00:0" << p << ":" << s;} else
if ((p>=10) and (p<60)) {if (s<10) cout << "00:" << p << ":0" << s;
else cout << "00:" << p << ":" << s;}}
if (p>=60) {
int h = p/60;
p = p%60;
if (h<10) { if (p<10) {
if (s<10) cout << "0" << h << ":" << "0" << p <<":0" <<s;
else cout << "0" << h << ":" << "0" << p <<":" <<s; } else {
if (s<10) cout << "0" << h << ":" << p <<":0" <<s;
else cout << "0" << h << ":" << p <<":" <<s;} } else {
if (p<10) { if (s<10) cout << h << ":" << "0" << p <<":0" <<s;
else cout << h << ":" << "0" << p <<":" <<s; } else {
if (s<10) cout << h << ":" << p <<":0" <<s;
else cout << h << ":" << p <<":" <<s;} } }
return 0;
}
Bài 5:
#include <bits/stdc++.h>
using namespace std;
int main () {
int n;
cin >> n;
int m=n;
int t100 = n/100;
n = n - t100 * 100;
int t50 = n/50;
n = n - t50*50;
int t20 = n/20;
n = n - t20*20;
int t10 = n/10;
n = n - t10*10;
int t5 = n/5;
n = n - t5*5;
int t2 = n/2;
n = n - t2*2;
int t1 = n;
if (m>=100) cout << t100 << " to menh gia 100" << endl;
if (t50!=0) cout << t50<< " to menh gia 50" << endl;
if (t20!=0) cout << t20<< " to menh gia 20" << endl;
if (t10!=0) cout << t10<< " to menh gia 10" << endl;
if (t5!=0) cout << t5<< " to menh gia 5" << endl;
if (t2!=0) cout << t2<< " to menh gia 2" << endl;
if (t1!=0) cout << t50<< " to menh gia 1" << endl;
return 0;
}
1. Viết chương trình nhập vào 1 số tự nhiên P. Tính và in ra màn hình các số lẻ và tổng các số lẻ từ 1 đến P. 2.Viết chương trình nhập vào 1 số tự nhiên N. Tính và in ra màn hình các số chẵn và tổng các số chẵn từ 1 đến N. 3. Viết chương trình nhập vào 1 số tự nhiên N. Tính tổng các số là ước của N. 4. Viết chương trình nhập vào 1 số tự nhiên N. Tính tổng các số là bội của 3 mà nhỏ hơn hoặc bằng N.
Câu 1:
Program HOC24;
var i,p: integer;
t: longint;
begin
write('Nhap P: '); readln(p);
t:=0;
for i:=1 to p do if i mod 2<>0 then t:=t+i;
write('Tong cac so le la: ',t);
readln
end.
Câu 2:
Program HOC24;
var i,n: integer;
t: longint;
begin
write('Nhap N: '); readln(n);
t:=0;
for i:=1 to n do if i mod 2=0 then t:=t+i;
write('Tong cac so chan la: ',t);
readln
end.
Câu 3:
Program HOC24;
var i,t,n: integer;
begin
write('Nhap N: '); readln(n);
t:=0;
for i:=1 to n do if n mod i=0 then t:=t+i;
write('Tong cac uoc cua ',n,' la: ',t);
readln
end.
Năm nay chúng ta sẽ đón tết NHÂM DẦN, để đếm ngược thời gian đến giao thừa e hãy viết chương trình nhập vào từ bàn phím một khoảng thời gian n (0<n<=5) nếu nhập sai yêu cầu nhập lại khi nào đúng thì in ra màn hình thông báo đếm ngược từng giây về 0:"XIN THONG BAO CHI CON ? GIAY NUA LA DEN GIAO THUA" cho đến khi hết khoảng thời gian đã nhập thì in ra dòng chữ:"HAPPY NEW YEAR 2022 - CHUC MUNG NAM MOI XUAN NHAM DAN"
Trong đó ? lần lượt là số giây còn lại
MỌI NGƯỜI VIẾT CHƯƠNG TRÌNH PASCAL NÀY GIÚP MÌNH VỚI MÌNH CẢM ƠN!
Bài 1: Hãy viết chương trình trong Pascal thực hiện các công việc sau:
a) Nhập 2 số thực a và b vào từ bàn phím
b) In ra màn hình tổng của 2 số a,b vừa nhập, với kết quả in ra có 1 chữ số ở phần thập phân
c) Lưu chương trình với tên có dạng hoten-lop
**Lưu ý: Trong chương trình phải sử dụng các lệnh xóa màn hình và dừng màn hình kết quả
------------Mình cần gấp, xin cảm ơn------------
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.
Viết chương trình nhập vào hai số nguyên a, b. sau đó xuất ra tổng hai số vừa nhập. yêu cầu viết và sử dụng hàm tính tổng (a,b) trong chương trình( viết chương trình python)
Mong mn giúp em ạ
Cho dãy A gồm N số nguyên (N nhỏ hơn hoặc bằng 200) số nguyên A1,A2,...An. Hãy viết chương trình nhập mảng A vào từ bàn phím và đưa ra màn hình tổng các phần tử chia hết cho 5. Bài 2: Viết chương trình nhập 1 xâu vào từ bàn phím và đưa ra màn hình xâu không chứa dấu cách.
Bài 1:
uses crt;
var a:array[1..200]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 5=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 5 la: ',t);
readln;
end.
Bài 2:
uses crt;
var st:string;
d,i:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln(st);
readln;
end.
1. Viết chương trình nhập vào một mảng các số nguyên. Tìm tổng các số.
2. Viết chương trình nhập vào một mảng các số nguyên. Tính và xuất tổng các số chẵn có trong mảng.
3. Viết chương trình nhập vào một mảng các số nguyên. Tính và xuất tổng các số lẻ có trong mảng.
4. Viết chương trình nhập vào một dãy các số nguyên. Hãy đưa ra màn hình có bao nhiêu số chẳn và bao nhiêu số lẻ trong dãy.
5. Viết chương trình nhập vào một dãy gồm N số nguyên. Cho biết có bao nhiêu số có giá trị chia hết cho 5 và không chia hết cho 3 trong dãy đó. Xuất số lượng đếm được và vị trí các số đó
6. Viết chương trình nhập vào một mảng các số nguyên. Tìm giá trị lớn nhất và vị trí của nó.
7. Viết chương trình nhập vào một mảng các số thực. Tìm giá trị nhỏ nhất và vị trí của nó.
8. Viết chương trình nhập vào một mảng các số nguyên. Sau đó nhập vào một số và tìm xem số ấy có trong mảng hay không, nếu có xuất vị trí.
9. Nhập một dãy số gồm N số nguyên. Tìm tổng bình phương các số(a21+ a22+ a23+… a2N)
10. Viết chương trình nhập vào một dãy số và sắp xếp theo thứ tự giảm dần.
11. Viết chương trình chèn thêm một số nguyên vào vị trí thứ k(k=1, k=5, k=9 hoặc k=N) của mảng số nguyên gồm N phần tử.
12. Viết chương trình xóa một phần tử thứ k (với k là số nguyên và 1<=k<=N. VD k=1, k=5, k=9 hoặc k=N) của mảng số nguyên gồm N phần tử.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cac so trong mang la: ',t);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln('Tong cac so chan la: ',t);
readln;
end.
1.Viết chương trình nhập một xâu ký tự gồm các ký tự từ “ a” đến “ z” và “A” đến “Z”. In ra màn in xâu đã nhập theo dạng chữ viết thường.
2.Viết chương trình đã nhập vào một số nguyên.Chuyển số đã nhập thành xâu số nguyên
Viết chương trình nhập vào từ bàn phím các số nguyên dương, khi người dùng nhập số có nhiều chữ số, thì chương trình sẽ tính tổng của các chữ số đó và in ra màn hình. (dùng Python để viết chương trình).
Ví dụ: khi người dùng nhập số 246 thì tổng bằng 2 + 4 + 6 = 12