#UVa:11799-Horror Dash

找尋最大值即是答案。

C++(0.012)

/*******************************************************/
/* UVa 11799 Horror Dash                               */
/* Author: LanyiKnight [at] knightzone.org             */
/* Version: 2015/01/03                                 */
/*******************************************************/
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
  int T;
  while( scanf("%d", &T) != EOF ){
    for( int testcase = 1 ; testcase <= T ; ++testcase ){
      int N;
      scanf("%d", &N);

      int speed, speedMax = 0;
      for( int i = 0 ; i < N ; ++i ){
        scanf("%d", &speed);
        speedMax = max( speed, speedMax ); 
      }

      printf("Case %d: %d\n", testcase, speedMax);
    }

  }
  return 0;
}

沒有迴響

本文還沒有迴響,快來搶頭香!

發表迴響