-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncionSuma1Segundo.cpp
39 lines (32 loc) · 1001 Bytes
/
funcionSuma1Segundo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// main.cpp
// funcionSuma1Segundo
//
// Created by Jaime Hisao on 10/12/18.
// Copyright © 2018 Jaime Hisao. All rights reserved.
//
#include <iostream>
using namespace std;
void checkCondition(int &hours, int &minutes, int &sec){
//Checks if Sum of Seconds will equal 60 seconds, if not, sum 1 to seconds
if(sec+1 != 60){
sec++;
}
//Checks if sum of seconds equals 60 seconds, if true, adds a minute and sets seconds to 0
if(sec+1 == 60){
minutes++;
sec = 0;
}
//Checks if sum of minutes equals 60, if yes, adds one to hour and sets minutes to 0
if (minutes+1 == 60) {
hours++;
minutes = 0;
}
}
int main(int argc, const char * argv[]) {
int hours, minutes, seconds; //Value Declaration
cin>>hours>>minutes>>seconds; //Value Input
checkCondition(hours, minutes,seconds); //Checks wether tu sum and change values
cout<<hours<<" "<<minutes<<" "<<seconds; //Prints
return 0;
}