1st commit
This commit is contained in:
parent
530e88c079
commit
1114096a41
33
Velocità.c
Normal file
33
Velocità.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//Calcolo della velocità in mph
|
||||||
|
#include <stdio.h>
|
||||||
|
int main(){
|
||||||
|
//Raccolta dati
|
||||||
|
int min;
|
||||||
|
int sec;
|
||||||
|
float km;
|
||||||
|
printf("Inserisci i minti: ");
|
||||||
|
scanf("%d",&min);
|
||||||
|
printf("Inserisci i secondi: ");
|
||||||
|
scanf("%d",&sec);
|
||||||
|
printf("Inserisci i chilometri percorsi: ");
|
||||||
|
scanf("%f",&km);
|
||||||
|
//Calcoli
|
||||||
|
int sec_tot;
|
||||||
|
sec_tot=(min*60)+sec;
|
||||||
|
float m;
|
||||||
|
float m_s;
|
||||||
|
m=km*1000;
|
||||||
|
m_s=m/sec_tot;
|
||||||
|
//Velocità in km/h. Uso la seguente proporzione (3600 sono i secondi in un ora):
|
||||||
|
//km : km_h = secondi_totali : 3600
|
||||||
|
float km_h;
|
||||||
|
km_h=km*3600/sec_tot;
|
||||||
|
//Velocità in mph
|
||||||
|
float mph;
|
||||||
|
mph=(km_h*1000)/1609.344;
|
||||||
|
//Output
|
||||||
|
printf("Velocità: %f m/s\n",m_s);
|
||||||
|
printf("Velocità: %f km/h\n",km_h);
|
||||||
|
printf("Velocità: %f mph",mph);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
35
Velocità.py
Normal file
35
Velocità.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
"""Calcolo della velocità in mph"""
|
||||||
|
|
||||||
|
|
||||||
|
# Dati iniziali
|
||||||
|
minuti = 21 # Tempo impiegato: 21" e 34""
|
||||||
|
secondi = 34
|
||||||
|
km = 4.1 # Distanza percorsa: 4,1 km
|
||||||
|
|
||||||
|
|
||||||
|
# Elaborazione
|
||||||
|
secondi_totali = minuti * 60 + secondi
|
||||||
|
|
||||||
|
|
||||||
|
# Velocità in m/s
|
||||||
|
metri = km * 1000
|
||||||
|
m_s = metri / secondi_totali
|
||||||
|
|
||||||
|
|
||||||
|
# Velocità in km/h. Uso la seguente proporzione (3600 sono i secondi in un ora):
|
||||||
|
# km : km_h = secondi_totali : 3600
|
||||||
|
|
||||||
|
|
||||||
|
km_h = km * 3600 / secondi_totali
|
||||||
|
|
||||||
|
#Velocità in mph
|
||||||
|
|
||||||
|
mph = (km_h * 1000) / 1609.344
|
||||||
|
|
||||||
|
|
||||||
|
# Output
|
||||||
|
print("Velocità:", round(m_s, 2), "m/s")
|
||||||
|
print("Velocità:", round(km_h, 2), "km/h")
|
||||||
|
print("Velocità:", round(mph, 2), "mph")
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user