URI Online Judge Solution 1047 Game Time with Minutes – Solution in C, C++, Java, Python and C#

URI Online Judge Solution URI Solution -Beginner

URI Online Judge Solution 1047 Game Time with Minutes – Solution in C, C++, Java, Python and C#

URI Online Judge Solution 1047 Game Time with Minutes  | Beginner
URI Problem Link –  https://www.urionlinejudge.com.br/judge/en/problems/view/1047

Problem Name: 1047 Game Time with Minutes
Problem Number : URI – 1047 Game Time with Minutes
Online Judge : URI Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)

URI Online Judge Solution 1047 Game Time with Minutes - Solution in C, C++, Java, Python and C#

URI 1047 Game Time with Minutes  Code in C / URI 1047  solution in C:

#include <stdio.h>
int main()
{

int
start_h, end_h, start_m, end_m, duration_h, duration_m;
scanf("%d %d %d %d", &start_h, &start_m, &end_h, &end_m);

duration_h = end_h - start_h;

if
(duration_h < 0)
{

duration_h = 24 + (end_h - start_h);
}


duration_m = end_m - start_m;
if
(duration_m < 0)

{

duration_m = 60 + (end_m - start_m);
duration_h--;
}


if
(start_h == end_h && start_m == end_m)

{

printf("O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)n");
}

else
printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)n", duration_h, duration_m);
return
0;
}

URI 1047 Game Time with Minutes  Code in C++ / URI 1047  solution in CPP:

#include <iostream>

using namespace
std;

int
main()
{

int
hi, mi, hf, mf;
int
ctrh = 0, ctrm = 0;

cin >> hi >> mi >> hf >> mf;

if
(hi == hf && mi == mf){
cout << "O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)" << endl;
return
0;
}


if
(hi == hf && mi != mf){
hi++;
while
(mi != mf)
{

ctrm++;
mi++;
if
(mi == 61)
mi = 1;
}


while
(hi != hf)
{

ctrh++;
hi++;
if
(hi == 25)
hi = 1;
}

}


while
(mi != mf)
{

ctrm++;
mi++;
if
(mi == 61){
mi = 1;
ctrh--;
}
}


while
(hi != hf)
{

ctrh++;
hi++;
if
(hi == 25)
hi = 1;
}



cout << "O JOGO DUROU " << ctrh << " HORA(S) E " << ctrm << " MINUTO(S)" << endl;

return
0;
}

URI 1047 Game Time with Minutes  Code in java/ URI 1047  solution in Java:

import java.util.Scanner;

public class
Main {

public static
void main(String[] args) {
int
start_h, end_h, start_m, end_m, duration_h, duration_m;

Scanner sc = new Scanner(System.in);

start_h = sc.nextInt();
start_m = sc.nextInt();
end_h = sc.nextInt();
end_m = sc.nextInt();

duration_h = end_h - start_h;

if
(duration_h < 0)
{

duration_h = 24 + (end_h - start_h);
}


duration_m = end_m - start_m;
if
(duration_m < 0)

{

duration_m = 60 + (end_m - start_m);
duration_h--;
}


if
(start_h == end_h && start_m == end_m)

{

System.out.printf("O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)n");
}

else

System.out.printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)n", duration_h, duration_m);

}

}

URI 1047 Game Time with Minutes  Code in Python / URI 1047  solution in Python:

URI Solution 1047 Game Time with Minutes  Code / URI 1047  solution in  C# (C Sharp):

Demonstration:

Just implement this in coding. Since having any problem just put a comment below. Thanks

Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1047  Game Time with Minutes  code in C, URI 1047  code in C++, URI Game Time with Minutes solution in C, URI solution, URI 1047 Game Time with Minutes  solution in C,URI 1047  solution in C++-CPP,URI 1047  solution in C# (C sharp),URI 1047  solution in Java,URI 1047 Game Time with Minutes  solution in Python, URI Game Time with Minutes problem solution

Leave a Reply

Your email address will not be published.