🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #9372

Re: Numeros y arrays

#9372
From: José Antonio Calvo
Date: Sun, 21 Jul 2002 16:40
53 lines
2531 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

El Sun, 21 Jul 2002 16:41:35 +0200, quantium escribi�:
> � sabes como podria hacer para que el siguiente programa me mostrase el 
> numero mas peque�o y el numero mas grande ?  
> 
> Otra duda, me han hablado sobre un metodo que se llama "metodo burbuja" 
> que es para ordenar los numeros de menos a mayor en un arrat. � sabes 
> 
> main()
> {
> 
> int i;
> int array[10];
> 
> for(i=0; i<10; i++) {
> 	printf(" numero: ");
> 	scanf("%d", &array[i]);
> 	}
> }
>

Esto ser�a el m�todo de la burbuja:

  int i,j,aux;
  for(i=0;i<10;i++){
    for(j=0;j<9;j++){
      if(array[j]>array[j+1]){
        aux=array[j];
        array[j]=array[j+1];
	array[j+1]=aux;
      }
    }
  }

Ahora para mostrar el mayor y menor bastar�a con:
printf("Mayor: %d , Menor: %d",array[9],array[0]);

Un saludo.

- -- 
Jos� Antonio Calvo <josh@escomposlinux.org>
Linux Registered User #194638
Powered by Debian GNU/Linux sarge
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9OuQHEY/neweI71kRAtDLAKDZzeGxZyBfWKdJaye90UU8kn4uwQCgropH
Wat46j035MhLfZpthnv4LS8=
=+qHA
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <slrnajlp02.2jn.josh@monegrux.micasa>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor-online.net!fu-berlin.de!nsnmpen1-lo.nuria.telefonica-data.net!nsnmpen2-lo.nuria.telefonica-data.net!antonio.escomposlinux.org!127.0.0.1!nobody
References: <3D3AC81F.5080207@lycos.es>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,9edd6153a53e25f5
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-07-21 09:45:21 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor-online.net!fu-berlin.de!nsnmpen1-lo.nuria.telefonica-data.net!nsnmpen2-lo.nuria.telefonica-data.net!antonio.escomposlinux.org!127.0.0.1!nobody
From: José Antonio Calvo <josh@monegrux.micasa>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Numeros y arrays
Date: Sun, 21 Jul 2002 18:40:40 +0200
Organization: ecolnet
Lines: 53
Sender: josh@193-153-251-164.uc.nombres.ttd.es
Message-ID: <slrnajlp02.2jn.josh@monegrux.micasa>
References: <3D3AC81F.5080207@lycos.es>
Reply-To: josh@escomposlinux.org
NNTP-Posting-Host: 213-98-107-123.uc.nombres.ttd.es
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: nsnmpen2-gest.nuria.telefonica-data.net 1027269920 14689 213.98.107.123 (21 Jul 2002 16:45:20 GMT)
X-Complaints-To: usenet@nsnmpen2-gest.nuria.telefonica-data.net
NNTP-Posting-Date: Sun, 21 Jul 2002 16:45:20 +0000 (UTC)
User-Agent: slrn/0.9.7.4 (Linux)