This web page requires JavaScript to be enabled.

JavaScript is an object-oriented computer programming language commonly used to create interactive effects within web browsers.

How to enable JavaScript?

Tìm max/min [C]

10cth1-2 August 1, 2011 0

Tìm max và trả về giái trị:

[codes=c]int max(int a[], int n)
{
  int max=a[0];
  for(int i=0; i<n; i++)
    if(a[i]>max)
      max=a[i];
  return max;
}[/codes]

TÌm max trong các phần tử nhỏ hơn x trong mảng:

[codes=c]int TimMax_X(int a, int n, int &x)
{
    int max=-32768;
    printf("\nNhap x:");
    scanf("%d",&x);
    for(int i=0;i<n;i++)
        if(
(a+i)<x&&(a+i)>max)
            max=
(a+i);
    return max;
}[/codes]


Last modified on March 31st, 2021 at 1:17 am

Nam Le
lequocnam



0 responds

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.