code[vs]-minimum and maximum number-integer processing-Ladder Bronze

Source: Internet
Author: User

Title Description Description

Enter n number, n<=100, find the smallest and largest number

Enter a description Input Description

First line an integer n

Next line n integers, each integer less than 231-1

Output description Output Description

Minimum and maximum number

Sample input Sample Input

4

1 2 3 4

Sample output Sample Output

1 4

Data range and Tips Data Size & Hint

No

Idea: This problem is relatively simple, you can put all the numbers into the array, and then a little use of the fast line can be finished, the output of the No. 0 and the first n-1

The code is as follows:

1#include <stdio.h>2#include <stdlib.h>3 intFunConst void*a,Const void*b)4 {5     return*(int*) a-* (int*) b;6 }7 intMain ()8 {9     intn,i;Ten     inta[10000]; Onescanf"%d",&n); A      for(i=0; i<n;i++) -     { -scanf"%d",&a[i]); the     } -Qsort (A,n,sizeof(int), fun); -printf"%d%d\n", a[0],a[n-1]); -     return 0; +}

code[vs]-minimum and maximum number-integer processing-Ladder Bronze

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.