Nếu có sai thì bạn nói mình nhé.
======================
#include <iostream> /*Khai báo thư viện iostream (Input/Output stream) */
using namespace std; /*Khai báo namespace std*/
int main(){
float C, F; /* Kiểu dữ liệu số thực*/
cin >> F; /* Nhập độ F */
cout <<"C = " << (F-32)/1.8; /*(F-32)/1.8 = (F-32)*5/9*/
return 0;
}
======================
#include <iostream>
using namespace std;
int main(){
float h,m,s; /*Kiểu dữ liệu số thực vì có thể nhập 1.5 giờ*/
cin >> h >> m >> s;
cout << "s: " << (h*3600)+(m*60)+s;
return 0;
}
======================
#include <iostream>
using namespace std;
int main(){
int h,m,s;
cin >> s;
h = s / 3600; /*Chia lấy phần nguyên "/" */
m = s % 3600 / 60; /*Chia lấy phần dư "%", lấy phần dư chia tiếp để lấy phần nguyên.(1)*/
s = s % 3600 % 60; /*(2)*/
cout << h << "h "<< m << "m "<< s << "s";
return 0;
}
===========================
(1): 3660 % 3600 được 1 dư 60, lấy 60 / 60 = 1 => 1 h 1 m.
(2):3666 % 3600 được 1 dư 66, lấy 66 % 60 được 1 dư 6 => 1h 1m 6s.