Use of N Max. Number INF

Source: Internet
Author: User

Input n

N Max. Min.

 

Input

5

1 5 2 3 6

Output

1 6

 

 

 

#include<iostream>#include<algorithm>using namespace std;int main(){    int  n, i, a[1000];    while(cin>>n)    {        for(i=0; i<n;i++)        cin>>a[i];        sort(a,a+n);cout<<a[0]<<" "<<a[n-1]<<endl;    }}    
View code

# Include <iostream>
# Include <algorithm>
Using namespace STD;
Int main ()
{
Int N, I, a [1000];
While (CIN> N)
{
For (I = 0; I <n; I ++)
Cin> A [I];
Sort (A, A + n );
Cout <A [0] <"" <A [n-1] <Endl;
}
}

 

 

 

 

 

 

#include<iostream>#include<algorithm>using namespace std;int main(){    int  n, i, a[1000],m1,m2;    while(cin>>n)    {        for(i=0; i<n;i++)        cin>>a[i];        if(i==0) m1=m2=a[0];        if(a[i]>m2)  m2=a[i];        if(a[i]<m1)   m1=a[i];cout<<m1<<" "<<m2<<endl;    }}    
View code

 

 

 

# Include <iostream>

# Include <algorithm>

Using namespace STD;

 

Int main ()

{

Int N, I, a [1000], M1, M2;

While (CIN> N)

{

For (I = 0; I <n; I ++)

Cin> A [I];

If (I = 0) M1 = m2 = A [0];

If (A [I]> m2) m2 = A [I];

If (A [I] <M1) M1 = A [I];

Cout <M1 <"" <m2 <Endl;

}

 

}

 

 

**************************************** ****************

 

 

# Include <iostream>

# Include <algorithm>

Using namespace STD;

# Define INF 1000000

Int main ()

{

Int N, I, a [1000], M1, M2;

While (CIN> N)

{

For (I = 0; I <n; I ++)

Cin> A [I];

 

M1 =-INF; M2 = inf;

If (A [I]> m2) m2 = A [I];

If (A [I] <M1) M1 = A [I];

 

Cout <M1 <"" <m2 <Endl;

}

}

 

 

**************************************** ***************

 

2's 31 Power ----------------------------- use of the calculator

 

# Include <iostream>

# Include <algorithm>

Using namespace STD;

 

# Define INF 1 <31

 

Int main ()

{

Int N, I, a [1000], M1, M2;

While (CIN> N)

{

For (I = 0; I <n; I ++)

Cin> A [I];

 

M1 =-INF; M2 = inf;

If (A [I]> m2) m2 = A [I];

If (A [I] <M1) M1 = A [I];

Cout <M1 <"" <m2 <Endl;

 

}

}

 

 

 

# Include <iostream>

# Include <algorithm>

Using namespace STD;

# Define INF 2147483648

 

Int main ()

{

Int N, I, a [1000], M1, M2;

While (CIN> N)

{

For (I = 0; I <n; I ++)

Cin> A [I];

M1 =-INF; M2 = inf;

If (A [I]> m2) m2 = A [I];

If (A [I] <M1) M1 = A [I];

Cout <M1 <"" <m2 <Endl;

}

}

 

 

 

 

 

 

 

**************************************** *****************************

Verify the power of 1 <31 2 to the power of 31 using a program

Use a program to calculate the power 31 of 1 <31 2

Use % d % u for data range format characters

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.