Topic 1386: Minimum digital time limit for rotating an array: 1 seconds Memory limit: 32 Mega Special: No submission: 5659 Resolution: 1273 Title Description: The first element of an array is moved to the end of the array, which we call the rotation of the array. Enter a rotation of an incrementally sorted array, outputting the smallest element of the rotated array. For example, the array {3,4,5,1,2} is a rotation of {1,2,3,4,5}, and the minimum value of the array is 1. Input: The input may contain multiple test samples, and for each test case, the first behavior of the input is an integer n (1<= n<=1000000): The number of elements that represent the rotated array. The second line of input includes n integers, where the range of each integer A is (1<=a<=10000000). Output: Corresponds to each test case, outputting the smallest element in the rotated array. Sample input: 53 4 5 1 2 sample output: 1
#include <iostream> #include <stdio.h>using namespace Std;int main () { int n; while (scanf ("%d", &n)!=eof) { int min =10000000,num; while (n--) { scanf ("%d", &num); if (num<min) { min = num; } } printf ("%d\n", min); } return 0;}
OJ Address
Sword refers to offer source-the smallest number of rotating arrays