generateSortOfRandomInt

generateSortOfRandomInt

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                                7年前关闭。
            
                    
该功能将是这样的。

int generateSortOfRandomInt(int X, int Y){

/*
Your program

*/

return randomINT that is always the same for X and Y
}


如果这会很好
generateSortOfRandomInt(5,15)!= generateSortOfRandomInt(15,5)

一个例子是像

int value1 = generateSortOfRandomInt(1, 3);  // 546547
int value2 = generateSortOfRandomInt(3, 1);  // 134566
int value3 = generateSortOfRandomInt(1, 3);  // 546547 THE SAME AS value1
int value4 = generateSortOfRandomInt(2, 3);  // 646621


谢谢

最佳答案

这是我想出的:

int generateSortOfRandomInt(int X, int Y)
{
    srand(x*x+y);

    return rand();
}

10-07 21:55