Answer:
Explanation:
The following code is written in Java and loops through 10 times. Each time generating 2 random dice rolls. If the sum is 10 it breaks the loop and outputs a "You Win" statement. Otherwise, it outputs "You Lose"
import java.util.Random;
class Brainly {
public static void main(String[] args) {
UseRandom useRandom = new UseRandom();
boolean youWin = false;
for (int x = 0; x<10; x++) {
int num1 = useRandom.getRandom(6);
int num2 = useRandom.getRandom(6);
if ((num1 + num2) == 10) {
System.out.println("Number 1: " + num1);
System.out.println("Number 2: " + num2);
System.out.println("You Win");
youWin = true;
break;
}
}
if (youWin == false) {
System.out.println("You Lose");
}
}
}
class UseRandom{
public int getRandom(int n)
{
Random r=new Random();
int rand=r.nextInt(n);
return rand;
}}
Answer:
Giving that: The following is a sequence of undo-log records written by 2 transactions T and U:
< START T >;
< T,A,10 >;
< START U >;
< U, B, 20 >;
< T, C, 30 >;
< U, D, 40 >;
< Commit U >;
< T, E, 50 >;
< Commit T >;
1. < START U >
Recovery action in this case will be undo(-1) and undo(0). All restored to its original Value
log records < T, A, 10 >, < T, abort >; as written out
2. < T, E, 50 >
Recovery action in this case will be undo(8) and redo(0). A and C is restored to its original value, B and D are set to 20 and 40
log records <T, C, 30 >, < T, A, 10 >, < T, abort > are written out
3. < Commit T >
Recovery action in this case will be redo(7) and redo(4). A and C are set to 10 and 30, B and D are set to 20 and 40
You'll need a helper variable for this, so depending on your programming language, the solution becomes:
int helper;
helper = arr[i];
arr[i] = arr[j];
arr[j] = helper;
Answer:
Explanation:
Let's do this in Python, first we need to convert the number into string in order to break it into a list of character, then we can replace the kth character with d. Finally we join all characters together, convert it to integer then output it
def setKthDigit(n, k, d):
n_string = str(n)
d_char = str(d)
n_char = [c for c in n_string]
n_char[k] = d_char
new_n_string = ''.join(n_char)
return int(new_n_string)
Answer:
Star Topology
Explanation:
Because the definition of Star Topoplogy is: In star topology each device in the network is connected to a central device called hub. Unlike Mesh topology, star topology doesn’t allow direct communication between devices, a device must have to communicate through hub. If one device wants to send data to other device, it has to first send the data to hub and then the hub transmit that data to the designated device.