我需要使用cin读取用户使用数据的一些数据这很容易,但问题是我需要数字不同。有没有办法快速完成,而无需在每次用户输入新号码时检查整个阵列(以查看是否有这样的号码)?
答案 0 :(得分:-1)
答案 1 :(得分:-1)
这很简单。
public final class Clock {
private int totalSeconds;
public Clock() {
this(0);
}
public Clock(int hour, int minute, int second) {
//TODO invoke this(...) with the correct amount of seconds
}
public Clock(int totalSeconds) {
this.totalSeconds = totalSeconds;
}
public void addClock(Clock that) {
this.totalSeconds += that.totalSeconds;
}
public void tick() {
//TODO increment totalSeconds
}
public void tickDown() {
//TODO decrement totalSeconds
}
public long getTotalSeconds() {
return totalSeconds;
}
public int getHour() {
//TODO: compute hour based on totalSeconds
}
public int getMinute() {
//TODO: compute minute based on totalSeconds
}
public int getSecond() {
//TODO: compute second based on totalSeconds
}
}
现在您将拥有输入数组中的值