Array #3
Autoverifica


JavaSiano
int v1[] = {1, 3, 10, -4, 3};
int v2[] = {2, 3, 11, 4, -3, -7};

calcola i valori assunti dalle variabili in ogni sequenza di istruzioni

  1. int n=Math.min(v1.length, v2.length);
    int v3[]=new int[n];
    for(int i=0; i < n; i++)
       v3[i] = v1[i]+v2[i];

  2. int n=Math.min(v1.length, v2.length);
    int r=0;
    for(int i=0; i < n; i++)
       r += (v1[i] == v2[i]) ? 1 : 0;

  3. int r1=0,
        r2=0;
    for(int i=0; i < v1.length; i++)
       r1 += v1[i];
    for(int i=0; i < v2.length; i++)
       r2 += v2[i];
    boolean r=(r1 == r2);
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki