因此我需要使用随机数制作2维数组,并将数字排除在乘法表中。它应该如下所示:
我现在的代码如下:
$(function () {
// Ensure if our request context doesn't have an ID we at least get something back.
function getContextRequestID(settings, defaultIfNotSet)
{
if (typeof settings.context.requestID !== "undefined")
{
return settings.context.requestID;
}
return defaultIfNotSet;
}
function writeToJsResult(method, settings)
{
var DefaultRequestID = -1;
var requestID = getContextRequestID(settings, DefaultRequestID);
$(".js-result").append('<p>' + method + ': Ajax request for page --> ' + settings.url + ' with ID of: ' + settings.context.requestID + '</p>');
}
$(document).ajaxSend(function (event, jqxhr, settings) {
writeToJsResult("Starting", settings);
});
$(document).ajaxError(function (event, req, settings) {
writeToJsResult("Error", settings);
});
$(document).ajaxComplete(function (event, req, settings) {
writeToJsResult("Complete", settings);
});
/* triggering all Ajax requests */
$('.js-btn-json').on('click', function () {
loadBBC();
loadBBC();
});
function loadBBC()
{
loadSite("http://www.bbc.com");
}
function loadCNN()
{
loadSite("http://www.cnn.com");
}
function loadSite(url)
{
// Not sure how you want to correlate them. For now using random.
// Perhaps a global running counter
// Perhaps a GUID/UUID
// http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
var requestID = getRandomInt(0, 100);
$.ajax({
url: url,
context: {
requestID: requestID
}
});
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
编辑:::这对我有用!
Random random = new Random();
int[,] array = new int[10, 10];
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
array[i, j] = random.Next();
Console.Write("\t{0}\t{1}" ,i,j);
}
答案 0 :(得分:0)
正如ThatBrianDude所建议的
static void Main(string[] args)
{
Random random = new Random();
int[,] array = new int[10, 10];
for (int i = 0;
i < 10;
i++)
{
for (int j = 0;
j < 10;
j++)
{
array[i,
j] = random.Next();
Console.Write("\t{0}",
array[i,
j]);
}
Console.Write("\n");
}
Console.ReadKey();
}
答案 1 :(得分:0)
可以像这样生成一个10x10的随机数数组:
var rnd = new Random();
var randomArray = Enumerable.Range(0,10).Select(x => {
return Enumerable.Range(0,10).Select(y => rnd.Next()).ToArray();
}).ToArray();
答案 2 :(得分:0)
我认为这应该适合你:
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, i, 0); // i = seekbar progress