خرید بک لینک

Vote count: 0

Is that even possible? I've tried to use the following code, but it's obviously wrong:

#include <stdio.h>
int scrambled( unsigned int a[], unsigned int b[], unsigned int len)
{
if (len=0)
    {
    retu 1;
    }
else
    {
    int sumA,sumB,i;
    for (i=0; i<len; i++)
        {
        sumA+=a[i];
        }
    for (i=0; i<len; i++)
        {
        sumB+=b[i];
        }
    if (sumA==sumB)
        {
        retu 1;
        }
    else    
        {
        retu 0;
        }
    }
}   

int scrambled( unsigned int a[], unsigned int b[], unsigned int len );

I assumed that two arrays with the same sum of values would also have the same values, but this is not the case. {2,2} and {3,1} have the same sum, but not the same values.

Is there any way I can check if, in another words, one array is a permutation of another with linear complexity time?

asked 22 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 5 مرداد 1395 ساعت: 10:45

صفحه بندی