#9651: 我的解法


dse12345z (dse12345z)

學校 : 不指定學校
編號 : 47834
來源 : [61.216.89.235]
最後登入時間 :
2024-07-15 17:37:35
d985. Gran Turismo 5 -- 學姊 | From: [114.43.215.74] | 發表日期 : 2015-02-13 19:04

#include <iostream>

#include <sstream>

using namespace std;

 

string intToChar(int number) {

ostringstream oss;

oss << number;

return oss.str();

}

 

int main() {

int cinArrayCount, cinArraySubCount;

cin >> cinArrayCount;

 

for (int runCinArrayCount = 0; runCinArrayCount < cinArrayCount; runCinArrayCount++) {

float sumSec = 0;

int bestLap = 0;

 

cin >> cinArraySubCount;

for (int runCinArraySubCount = 0; runCinArraySubCount < cinArraySubCount; runCinArraySubCount++) {

int cinMinute;

int cinSecond;

 

cin >> cinMinute;

cin >> cinSecond;

sumSec += (cinMinute * 60) + cinSecond;

 

if (runCinArraySubCount == 0) {

bestLap = (cinMinute * 60) + cinSecond;

}

 

if (bestLap > (cinMinute * 60) + cinSecond) {

bestLap = (cinMinute * 60) + cinSecond;

}

}

cout << "Track " + intToChar(runCinArrayCount + 1) + ":" << endl;

 

int minute = bestLap / 60;

int sec = bestLap % 60;

 

cout << "Best Lap: " + intToChar(minute) + " minute(s) " + intToChar(sec) + " second(s)." << endl;

 

minute = (sumSec / cinArraySubCount) / 60;

sec = (int)(sumSec / cinArraySubCount) % 60;

 

cout << "Average: " + intToChar(minute) + " minute(s) " + intToChar(sec) + " second(s)." << endl;

}

return 0;

}

 

參考看看 :D 


 
ZeroJudge Forum