1.

/**
* ACM Training 2009
* ACM Contest Problem # 19.09. "Alarm Clock"
* Link: http://uva.onlinejudge.org/contests/227-44fb9aab/11677.pdf
*
* @author Felix Dietrich
* @version 1.0, 09/20/2009
*
* Methode: Simulation
* Status : Accepted
* Runtime: 0.160
*/

import java.util.*;

public class Main
{
public static class Time
{
int minutes;

public Time(int hour, int minute)
{
minutes = hour*60+minute;
}

/**
* returns minutes between this and time
* @param time
* @return
*/
public int compareTo(Time time)
{
return (time.minutes - this.minutes + 24*60) % (24*60);
}

}

public static void main(String... args)
{
Scanner sc = new Scanner(System.in);
Time t1;
int h1,m1,h2,m2;

while(true)
{
h1 = sc.nextInt();
m1 = sc.nextInt();
h2 = sc.nextInt();
m2 = sc.nextInt();

if(h1 == 0 && m1 == 0 && h2 == 0 && m2 == 0)
return;

t1 = new Time(h1, m1);
System.out.println(t1.compareTo(new Time(h2, m2)));
}
}
}

2.

/**
* ACM Training 2009
* ACM Problem #11677 - Alarm Clock
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=78&page=show_problem&problem=2724
*
* @author Dennis Wilfert
* @version 1.0, 09/20/2009
*
* Status : Accepted
* Runtime: 0.072
*/

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

public static void main(String[] args) throws IOException {

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer = new PrintWriter(new BufferedOutputStream(System.out));
StringTokenizer token;

token = new StringTokenizer(reader.readLine());
// Zeit in Minuten umrechnen
int m1 = Integer.parseInt(token.nextToken())*60+Integer.parseInt(token.nextToken());
int m2 = Integer.parseInt(token.nextToken())*60+Integer.parseInt(token.nextToken());

while (m1+m2!=0) {

// Ist m2 < m1, dan 24 Stunden zu m2 dazurechnen.
writer.println(m2 < m1 ? (m2+1440 - m1) : (m2 > m1 ? (m2 - m1) : 1440));

token = new StringTokenizer(reader.readLine());
// Zeit in Minuten umrechnen
m1 = Integer.parseInt(token.nextToken())*60+Integer.parseInt(token.nextToken());
m2 = Integer.parseInt(token.nextToken())*60+Integer.parseInt(token.nextToken());

}
writer.flush();
}
}