lundi 2 décembre 2019

I dont understand whats wrong with my program? Its for c++

//Prvi:
button1_click()
{
    Int N=Convert.ToInt32(Textbox1.Text);
    double P=1;
    For(int i=1; i<=N; i++)
    {
        P*=(i*i +1)/(i + 1);
    }
    TextBox2.Text=P.ToString();
}

//Drugi:
Button1_Click()
{
    string s=textbox1.text;
    Int br=0;
    For(int i=0; i<s.length; i++)
    {
        If(convert.ToInt32(s[i]) <5)
        {
            Br++;
        }
    }
    TextBox2.text=br.ToString();
}

//Treci:
Button1_click()
{
    Int br=0;
    Int s=0;
    For(int i=0; i<listbox1.items.count; i++)
    {
        If(listbox1.items[i]%2==0)
        {
            br++;
            s+=listbox1.items[i];
        }
    }
    Double a=s/br;
    Textbox1.text=a.ToString();
}

//Cetvrti:
Public bool prost(int b)
{
    Bool p=true;
    For(int i=2; i<br; i++)
    {
        If(b%i==0)
        {
            p=false;
        }
    }
    return p;
}
Button1_click
{
    Int br=0;
    For(int j=0; i<listbox1.items.count; j++)
    {
        If(prost(listbox1.items[j]))
        {
            br++;
        }
    }
    TextBox1.Text=br.ToString();
}

The console reads an integer m, then an integer integer. Print the lengths of the sequence of numbers consisting of at least m consecutive elements to which each future number applies is greater than the preceding number. For example. if number m = 2 (minimum sequence length) and give the integers: 1, 2, 3, 2, 0, 5, 7,9,10, 2, 3 One sequence of numbers is: 1, 2, 3 --- length 3> = m (each subsequent element> preceding this sequence). next: 5, 7,9,10 --- length 4> = m and: 2, 3 --- length 2> = m Only the lengths should be printed on the screen ie: 3 4 2

Aucun commentaire:

Enregistrer un commentaire