Where's the trash?



  • We need to put the same weight in the thermal range from the first and second. It's like it's taken, but when the third mass is removed, it's made of "musorous values."

    #include <iostream>
    #include <time.h>
    using namespace std;
    

    void main()
    {
    const int size = 10, size1 = 20;
    int massA[size], massB[size], massC[size1];
    srand(time(NULL));
    for (int i = 0; i < size; i++)
    {
    massA[i] = rand() % 10;
    cout << massA[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < size; i++)
    {
    massB[i] = rand() % 10;
    cout << massB[i] << " ";
    }
    for (int z=0, i = 0; z<size, i < size; i++,z++)
    {
    for (int j = 0; j < size; j++)
    {
    if (massA[i] != massB[j]) {
    massC[z] = massA[i];
    cout << massA[i] << " ";
    }
    }

    }
    for (int i = 0; i &lt; size1; i++)
    {
        cout &lt;&lt; massC[i] &lt;&lt; " ";
    }
    
    system("pause");
    

    }



  • Your massC is filled with values in

    if (massA[i] != massB[j]) {
                    massC[z] = massA[i];
                    cout << massA[i] << " ";
    }
    

    Consequently, it will not always have debris in it, because you have declared, but did not injure, the masses in the remaining areas, you rewrite your data.

    https://stackoverflow.com/questions/629017 the initialization of the zeros




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2