Mi sto approcciando nel mondo della programmazione . Vorrei creare un programma che mi visualizzi la somma di elementi con n inserito con tastiera.
esp.
vettore (1,5,7,8,9,1)
n= 2
somma = 6-15-10 ecc..
codice:Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim v(10), i, somma, c, n As Integer Label1.Text = "" Label2.Text = "" Randomize() n = cint (textbox1.text) For i = 1 To 10 v(i) = 1 + Int(Rnd() * 3) Label1.Text = Label1.Text & v(i) & "-" if i mod n = 0 then somma = somma + v(i) Label2.Text = somma end if Next Label1.Text = Microsoft.VisualBasic.Left(Label1.Text, Len(Label1.Text) - 1) End Sub End Class
ma purtroppo non mi risulta l'esercizio.....

Rispondi quotando