URI Online Judge Solution 1046 Game Time – Solution in C, C++, Java, Python and C#
URI Online Judge Solution 1046 Game Time | Beginner
URI Problem Link – https://www.urionlinejudge.com.br/judge/en/problems/view/1046
Problem Name: 1046 Game Time Solution
Problem Number : URI – 1046 Game Time code
Online Judge : URI Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)
URI 1046 Game Time Code in C / URI 1046 solution in C:
#include <stdio.h>
int main()
{
int strtTm, endTm, durationTm;
scanf("%d %d", &strtTm, &endTm);
durationTm = endTm - strtTm;
if (durationTm < 0)
{
durationTm = 24 + (endTm - strtTm);
}
if (strtTm == endTm)
{
printf("O JOGO DUROU 24 HORA(S)n");
}
else printf("O JOGO DUROU %d HORA(S)n", durationTm);
return 0;
}
URI 1046 Game Time Code in C++ / URI 1046 solution in CPP:
#include <iostream>
using namespace std;
int main()
{
int i, f;
int ctr = 0;
cin >> i >> f;
if(i == f){
cout << "O JOGO DUROU 24 HORA(S)" << endl;
return 0;
}
while(i != f)
{
ctr++;
i++;
if(i == 25)
i = 1;
}
cout << "O JOGO DUROU " << ctr << " HORA(S)" << endl;
return 0;
}
URI 1046 Game Time Code in java/ URI 1046 solution in Java:
import java.util.Scanner;
public class URI_1046 {
public static void main(String[] args) {
int strtTm, endTm, durationTm;
Scanner sc = new Scanner(System.in);
strtTm = sc.nextInt();
endTm = sc.nextInt();
durationTm = endTm - strtTm;
if (durationTm < 0)
{
durationTm = 24 + (endTm - strtTm);
}
if (strtTm == endTm)
{
System.out.printf("O JOGO DUROU 24 HORA(S)n");
}
else System.out.printf("O JOGO DUROU %d HORA(S)n", durationTm);
}
}
URI 1046 Game Time Code in Python / URI 1046 solution in Python:
URI Solution 1046 Game Time Code / URI 1046 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 1046 Game Time code in C, URI 1046 Game Time code in C++, URI Game time solution in C, URI solution, URI 1046 solution in C,URI 1046 solution in C++-CPP, URI 1046 solution in C# (C sharp),URI 1046 solution in Java,URI 1046 Game Time solution in Python,