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?

DÃY TĂNG DẦN

10cth1-2 October 27, 2010 1
#include <stdio.h>

void main() {
  int a[10], i, maxstart, maxend, maxlen, tmpstart, tmpend, tmplen;

  printf("\nNhap vao 10 phan tu nguyen cua day :");
  for (i = 0; i < 10; i++)
    scanf("%d", & a[i]);
  printf("Day da cho :\n");
  for (i = 0; i < 10; i++)
    printf("%6d", a[i]);

  maxstart = maxend = tmpstart = tmpend = 0;
  maxlen = tmplen = 1;
  for (i = 1; i < 10; i++) {
    if (a[i] < a[tmpend]) {
      if (maxlen < tmplen) {
        maxstart = tmpstart;
        maxend = tmpend;
        maxlen = tmplen;
      }
      tmpstart = tmpend = i;
      tmplen = 1;
    } else {
      tmplen++;
      tmpend++;
    }
  }
  if (maxlen < tmplen) {
    maxstart = tmpstart;
    maxend = tmpend;
  }
  printf("\nDay tang co so phan tu nhieu nhat la : \n");
  for (i = maxstart; i <= maxend; i++)
    printf("%6d", a[i]);
  getch();
}

Last modified on December 19th, 2020 at 7:05 pm

Nam Le
lequocnam



One respond

  1. aodensitinh_035 says:

    thần chú j thế này [emot]stupid[/emot] .

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.