๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Arrays y C

#9369
From: {EiRoN}
Date: Sun, 21 Jul 2002 14:17
53 lines
2683 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 21 Jul 2002 00:21:40 +0200, quantium wrote:
> Hola a todos!
    Hola
    
> Este programa que voy a poner a continuacion lo que hace es pedir al 
> usuario 30 numeros para despues poder sumarlos. Yo me quedo atascado a 
> la hora de realizar esta suma total ๏ฟฝalguien me hecha una mano? Un 
> saludete a todos.

    A ver si te puedo ayudar un poco :)
    
> 
> main()
> {
>   int i;
>   int array[30];

    int suma=0; /* entero con signo para almacenar el resultado de la 
                   suma */
> 
    for(i=0; i<30; suma+=array[i++]) { /* modificamos el for, y en el
                                          contador sustituimos i++ por
                                          suma+=array[i++], esto
                                          incrementa en uno i, y suma
                                          al valor de suma el valor
                                          contenido en el offset i++
                                          del array */
>    printf(" numero: ");
>    scanf("%d", &array[i]);
>     }
    printf("la suma total es: %d\n",suma); /* ponemos el valor de la
                                              suma en la salida
                                              estandar por defecto */
> }
>

Saludos :)

- -- 
- - Andres J. Diaz "{EiRoN}" <eiron@phreaker.net> -
- - The Nexus Zone Networking Departament         -
- - KeyID: 0x0FC56BAA in x-hkp://pgp.rediris.es   -
- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9OsJxf9QmLQ/Fa6oRAtzTAJ9HjzXSgp/Am7WrqtUNiLnXIPdtwQCcC7p0
lYv/pkT/XVQxiEGHNFQ0A1Y=
=6IQR
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <slrnajlgj9.20f.eiron@hermes.thenexuszone.ods.org>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!cm97184.red.mundo-r.COM!not-for-mail
References: <3D39E274.9050800@lycos.es>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,9c151734aac07880
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-07-21 07:14:52 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!cm97184.red.mundo-r.COM!not-for-mail
From: {EiRoN} <eiron@phreaker.net>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Arrays y C
Date: Sun, 21 Jul 2002 16:17:21 +0200
Lines: 53
Message-ID: <slrnajlgj9.20f.eiron@hermes.thenexuszone.ods.org>
References: <3D39E274.9050800@lycos.es>
Reply-To: eiron@phreaker.net
NNTP-Posting-Host: cm97184.red.mundo-r.com (213.60.97.184)
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: fu-berlin.de 1027260891 29227037 213.60.97.184 (16 [147002])
X-Orig-Path: hermes.thenexuszone.ods.org!news
X-Editor: Vim-601
User-Agent: slrn/0.9.7.4 (Linux)