QUESTION
A sorted array A[ ] with distinct elements is rotated at some unknown point, the task is to find the minimum element in it.\nExpected Time Complexity: O(Log n)\nInput:\nThe first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consist of two lines. The first line of each test case consists of an integer N, where N is the size of array.\nThe second line of each test case contains N space separated integers denoting array elements.\nOutput:\nCorresponding to each test case, in a new line, print the minimum element in the array.\nConstraints:\n1<=T<=100\n1<=N<=500\n1<=A[i]<=1000.
“TESTCASE_1”: “1\n5\n4 5 1 2 3\n###—###SEPERATOR—###—\n1”, “TESTCASE_2”: “1\n5 \n8 10 2 4 6\n###—###SEPERATOR—###—\n2”, “TESTCASE_3”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0
ANSWER
#include <iostream>
using namespace std;
void printv(int a[],int n)
{
int i,min;
min=a[0];
for(i=1;i<n;i++)
{
if(a[i]<min)
min=a[i];
}
cout<<min<<endl;
}
int main()
{
int n,i,j,a[100];
cin>>n;
for(i=0;i<n;i++)
{
int m;
cin>>m;
for(j=0;j<m;j++)
cin>>a[j];
printv(a,m);
}
return 0;
}