08-Language Primer-08-5 number for maximum

Source: Internet
Author: User

Title address: http://acm.nyist.net/JudgeOnline/problem.php?pid=31?? Describe
Design a program that takes the minimum and maximum numbers from 5 integers
Input
Enter only one set of test data, five positive integers not greater than 10,000
Output
Output two numbers, the first is the minimum of these five numbers, the second is the maximum value in these five numbers, and two numbers are opened with a blank.
Sample input
1 2 3) 4 5
Sample output
1 5? #include <stdio.h>

#define MAX_NUM 10000
#define MIN_NUM 0

int main ()
{
???? int min = max_num;
???? int max = Min_num;
????
???? int readnum = 0;
???? while (scanf ("%d", &readnum)! = EOF)
???? {
????????? if (Readnum < min)
????????? {
?????????????? min = Readnum;
????????? }
?????????
????????? if (Readnum > Max)
????????? {
?????????????? max = Readnum;
????????? }
???? }
????
???? printf ("%d%d\n", Min,max);
????
???? return 0;
}??? Note that the topics in this topic require the scope of input to find the most recommended code is only used stl OK, cow!
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace Std;
int main ()
{
???? int a[5];
???? Copy (istream_iterator<int> (CIN),istream_iterator<int> (), a);
???? Cout<<*min_element (a,a+5) << "" <<*max_element (a,a+5) <<endl;
}???????

???

08-Language Primer-08-5 number for maximum

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.