Write a C# program to generate Lists of random 5 elements each containing only binary numbers like 1 or 0 only such that there is only one 1 in the list in any random position and the rest four elements are zeroes. . For eg: (10000) or (01000) or (00100) or (00010) or (00001).
/* PLease read all the comments, */
/* Source code*/
using System;
public class Solution{
static public void Main (){
int TOTAL = 5;
Random r = new Random();
//Create array for 5 different place
int []a= new int[TOTAL];
for(int i=0;i<TOTAL;i++)
a[i] = i;
//loop to decide which index can be
replaced by 1
for (int i = TOTAL - 1; i > 0;
i--)
{
int j = r.Next(0, i+1);
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
//Now we have different place for 1, fill it at specified and
//fill rest position with 0
//like if array ith value is 3, so fill 1 at index 3 and rest place
would break
//like 00010
//Create static string based on Size which is here TOTAL = 5
//For this, below s variable would be finally "00000"
string s = "";
for(int i=0;i<TOTAL;i++)
s +="0";
//Now create total TOTAL string with value of s
string [] data = new string[TOTAL];
for(int i=0;i<TOTAL;i++)
data[i] = s;
//Now replace by 1 in each string array for specific manner made by
randomized algorithm by
// first for loop
for(int i=0;i<TOTAL;i++)
{
//Convert the current to charArray for easy change in its
respective index by 1
char [] charArray = data[i].ToCharArray();
//Now change by 1 in specific index, deciding it should be
repeatative
charArray[a[i]] = '1';
//Again convert into string and replace by reassign
data[i] = new string(charArray);
}
//Now show the all resultant string
for(int i=0;i<TOTAL;i++){
Console.WriteLine(data[i]);
}
//NOTE: if you want to check for other value like 6 or 10, just
change value of
//TOTAL declared at begining of program
}
}
/* Editor screen*/

/* Output screen*/
/* Each time, you run you will have different output*/




/* That's all . Thanks*/
Write a C# program to generate Lists of random 5 elements each containing only binary numbers...
Write a C# program to generate 2 Lists of random 5 elements each containing only binary numbers like 1 or 0 only such that there is only one 1 in the list in any random position and the rest four elements are zeroes. Create another list of 3 elements and such that there are random 1s or 0s. And concatenate these 3 Lists together to produce "one List" named "datablock".
Write a program in C to generate random numbers. The program recieves 4 items on activation through argv: 1. Name of the data file 2. Number of items for program to generate 3. Range of numbers 4. Seed of the random number generator Example run: ./rand datafile.txt 20 1000 3127 Program must convert all numbers to ints using atoi(), must save all parameters into variables, opens the data file to write the random numbers into it, program loops to generate...
**C++ only, use standard library, no vectors Write a program to generate a list of 5000 random numbers between 1 and 10,000 stored in an array. Sorts: Print out the middle 50 numbers of the original list to show the results. Now sort the original numbers using bubble sort. Print out the number of swaps made. Now sort the original numbers using selection sort. Print out the number of swaps made. Now sort the original numbers using insertion sort. Print...
write program above in C only
Write a program to find statistics on some random numbers. Seed the random number generator with time. In a for loop generate 12 random numbers between the values of 2 and 20. Print the numbers. As the numbers are generated, find the following: the number of even numbers (those evenly divisible by 2) e the sum of the even numbers the product of the even numbers the maximum value of all the numbers e
In C... Write a program to simulate a pick-5 lottery game. Your program must generate and store 5 distinct random numbers between 1 and 9 (inclusive) in an array. The program prompts the user for: an integer random seed five distinct integers between 1 and 9 (which are stored in another array) The program then compares the two arrays to determine if they are identical. If the two arrays are identical, then the user wins the game. otherwise the program...
Write a Java program named BSTree.java that will: 1) Generate 20 random integer numbers ranging from 1-99. 2) Build a Binary Search Tree using this set of numbers. Write the add method. 3) After building the tree, display the data into three formats: prefix order, infix order, and postfix order. 4) Write a method to delete an element from the Binary Search Tree. First search the item in your TREE and then delete it.
PYTHON: Using Lists and Arrays! 5. In a program, write a function that accepts two arguments: a list, and a number n. The program should generate 20 random numbers, in the range of 1 through 100, and assign each number to the list. The program should also ask the user to pick a number from 1 through a 100 and assign that number to n. The function should display all of the number in the list that are greater than...
a) Write a program (or use Excel) to generate random numbers between 0 and1. The distribution in this case is U -Un the uniform distribution on (0,1). The pmf for the uniform in this case is g (x) = 1 for 0 < x < 1 b) Choose a function f(x) with domain containing the interval (0,1). Be creative with the function you choose, 1/(x+1), 1/x ,etc functions use a continuous function such as e-4x, sin(2?). x, log(x), xlog(x), Do...
Write a program in C that creates an array of 100 random numbers from 0-99. The program sums the random numbers and prints the sum. It then writes the numbers to a new file using open, close and write. Then looks in the current directory for files that match the pattern “numbers.XXXX”. For each file, open the file and read the file. You can assume that the file will contain 100 integers. Sum the integers. Print the filename and the sum...
Write a C++ program to define a class having a 4x4 matrix. Generate 32 random numbers 1-10, in an output.txt file. Fill the generated numbers in two such class objects (first 16 numbers in one matrix and next 16 numbers in another. Create member functions each for adding, subtracting and multiplication of matrices. Write the algorithm defining steps of your program.