Tuesday, January 22, 2019

How many seconds are they?

Write a program that converts to seconds a given amount of years, days, hours, minutes and seconds.

Input : The input consists of five natural numbers that represent the years, days, hours, minutes and seconds, respectively.

Output : Write the total number of seconds represented by the input.

Observation : You may assume all the years have 365 days.

#include <iostream>
using namespace std;

int main () { 
    int a, d, h, m, s;
    cin >> a >> d >> h >> m >> s;
    a = a*365*24*3600;
    d= d*86400;
    h=h*3600;
    m=m*60;
    
    int segons;
    segons= a+d+h+m+s;
    cout << segons << endl;
}

No comments:

Post a Comment

Modelo OSI

Open System Interconnection , Interconexión de Sistemas Abiertos, es un modelo para estudiar las categorías en que se pueden dividir los pr...