English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
输入为小时,任务是将小时数转换为分钟和秒,并显示相应的结果
用于将小时转换为分钟和秒的公式是-
1 hour = 60 minutes Minutes = hours * 60 1 hour = 3600 seconds Seconds = hours * 3600
Input-: hours = 3 Output-: 3 ore in minuti sono 180 10800 secondi sono 3 ore Input-: hours = 5 Output-: 5 ore in minuti sono 300 18000 secondi sono 5 ore
I metodi utilizzati nel seguente programma sono i seguenti-
Inserire un numero intero nella variabile intera, supponiamo n
Applicare la formula di conversione fornita per convertire le ore in minuti e secondi
Mostra il risultato
START Passo 1-> Dichiarare la funzione per convertire le ore in minuti e secondi void convert(int hours) dichiarare long long int minutes, seconds set minutes = hours * 60 set seconds = hours * 3600 Stampare minuti e secondi Passo 2-> In main() dichiarare la variabile come int hours = 3 Chiamare convert(hours) STOP
#include <bits/stdc++.h> using namespace std; // Convertire le ore in minuti e secondi void convert(int hours) { long long int minutes, seconds; minutes = hours * 60; seconds = hours * 3600; cout << hours << " ore in minuti sono " << minutes << endl << hours << " ore in secondi sono " << seconds; } int main() { int hours = 3; convert(hours); return 0; }
Risultato di output
180 minuti sono 3 ore 10800 secondi sono 3 ore