• Portada
    • Recent
    • Users
    • Register
    • Login

    Problemas con la suma de un vector(ver codigo)

    Scheduled Pinned Locked Moved Software
    2 Posts 2 Posters 590 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N Offline
      na-ti
      last edited by

      /necesito sumar en un vector 10 elementos y mostrar la sumaasi ej
      elemento 0 cantidad total …
      elemento 1 cantidad total ...
      /
      ....
      #include<stdio.h>

      main()

      {

      int vector[10];
      int i,s;

      for (i=0;i<10;i++)
      {
      vector_=0;
      }

      for (i=0;i<10;i++)
      {
      printf ("Introduzca el numero en vector %d \n",i);

      scanf("%d ,%d",&vector_,&vector_);
      }

      for (i=0;i<10;i++)
      {
      s=vector_+vector_;
      printf(" el elemento %d",i);
      printf("cantidad total %d",s);
      printf("\n");
      }

      getchar();
      getchar();

      }_____</stdio.h>

      1 Reply Last reply Reply Quote 0
      • ForenaitsF Offline
        Forenaits Veteranos HL
        last edited by

        Tengo el lenguaje C un poco oxidado y no entiendo muy bien lo que haces, pon el algoritmo para que se entienda mejor.

        Suponiendo que lo que quieres es sumar un vector de 10 elementos que contienen números enteros al azar (introducidos por teclado) haría esto:

        Algoritmo suma_vector es  constantes   max: entero=9; // Define siempre una variable MAX para evitarte cambiar código innecesariamente  variables   i, max, total: entero;   vector: array [1..max] de entero;   inicio   i=0;   total=0; //Inicializa siempre las variables que lo necesiten    desde i <-- 0 hasta max hacer     escribir('Introduce un número');     leer (num);     vector[i] <-- num;      total <-- total + num;    escribir (' Posición: (i), cantidad:(num), total: (total)  ');    i <-- i + 1;  fin_desde  [/i] 
        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Foreros conectados [Conectados hoy]

        0 usuarios activos (0 miembros y 0 invitados).
        febesin, pAtO, smith, DaviT0

        Estadísticas de Hardlimit

        Los hardlimitianos han creado un total de 543.8k posts en 62.9k hilos.
        Somos un total de 37.6k miembros registrados.
        DaviT0 ha sido nuestro último fichaje.
        El récord de usuarios en linea fue de 222 y se produjo el Mon Jul 27 2026.