和小学的题目结果还有点不一样,呵呵,小学的题目是要求指针完全重合,而且不完全是整数的。
public class GetTime { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int ch =0;
int h = 0;
int m = 0;
int s = 0;
StringBuffer sb = new StringBuffer();
for(h=0;h<12;h++){
for(m=0;m<60;m++){
for(s=0;s<60;s++){
ch = h*5+m/12;
System.out.println(m/12);
if(m==s&&ch==m)
sb.append(","+h+":"+m+":"+s);
}
}
}
System.out.println("time="+sb.toString().substring(1));
}}
public class GetTime { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int ch =0;
int h = 0;
int m = 0;
int s = 0;
StringBuffer sb = new StringBuffer();
for(h=0;h<12;h++){
for(m=0;m<60;m++){
for(s=0;s<60;s++){
ch = h*5+m/12;
System.out.println(m/12);
if(m==s&&ch==m)
sb.append(","+h+":"+m+":"+s);
}
}
}
System.out.println("time="+sb.toString().substring(1));
}}
闪了,另外一个回来再整。可以倒过来考虑,实际上是到遇到第4个商店之后遇到第5个人喝光了酒。
public class Test{
public static void main(String[] args) {
for(int h=0;h<120;h+=5) {
for(int m=0;m<60;m++) {
for(int s=0;s<60;s++) {
if(((h>60)?h-60:h) == m && m== s) System.out.println(h/5+":"+m+":"+s);
}
}
}
}
}
输出:
0:0:0
1:5:5
2:10:10
3:15:15
4:20:20
5:25:25
6:30:30
7:35:35
8:40:40
9:45:45
10:50:50
11:55:55
13:5:5
14:10:10
15:15:15
16:20:20
17:25:25
18:30:30
19:35:35
20:40:40
21:45:45
22:50:50
23:55:55
public class Test{
public static void main(String[] args) {
for(int h=0;h<120;h+=5) {
for(int m=0;m<60;m++) {
for(int s=0;s<60;s++) {
if(((h>=60)?h-60:h) == m && m== s) System.out.println(h/5+":"+m+":"+s);
}
}
}
}
}
输出:
0:0:0
1:5:5
2:10:10
3:15:15
4:20:20
5:25:25
6:30:30
7:35:35
8:40:40
9:45:45
10:50:50
11:55:55
12:0:0
13:5:5
14:10:10
15:15:15
16:20:20
17:25:25
18:30:30
19:35:35
20:40:40
21:45:45
22:50:50
23:55:55
public static void main(String args[]){
for(int i=0;i<=86400;i++){
if((6*i)%360==(0.1*i)%360){
if((0.1*i)%360==(1/120.0)*i%360){
System.out.println(i/3600+":"+i%3600/60+":"+i%3600%60/60);
}
}
}
}}