Computer Science, asked by shaikhjamshed248, 6 months ago

IREM
Three people are playing a game in which one person is selected first, the second person gives the
selected person a number N, and the third person also gives the selected person a number M
The selected person has to maximize the number given by the second person in a way that
1 (S)he can maximize the number given by the second person only by swapping the adjacent two
digits of the number
2 The number that the third person gives is the maximum number of swaps allowed
Find the maximum number that the selected person can achieve
Input Specification:
input1: The number N
input2: The number M
Note: The number Nis given in the string format as input.
Output Specification:
The maximum number the person can achieve in M swaps.
Example 1:
inputi: 1234
input2: 2
Output: 3124​

Answers

Answered by mandalshubhamkumar85
0

Answer:

Amit is writing a text file handling program .He has written the following code. As a programmer, help him to successfully execute the given task

f=_______("book.txt"). Line#1

str=f._______() Line#2

L=str.split()

count_char=0

for i in L:

count_char=count_char+len(i)

print(count_char)

f.close()

fl= open("Book.txt", "a")

name = input("Enter a book name") =

_____________#Line3

_____________ #Line4

a)Fill the blank in Linel so that the file will be opened.

b) In which mode file "Book.txt" will be opened in Linel c) Write the function in Line2 to read first 20 characters from the file "Book.txt"

d) Write the statement in Line3 to write the book name entered by the user into the

file "Book.txt"

e) Write the statement in Line4 to close the file "Book.txt" which is opened in "a" mode.

  • f) Write the position of file pointer when the file is opened in append mode

Explanation:

Amit is writing a text file handling program .He has written the following code. As a programmer, help him to successfully execute the given task

f=_______("book.txt"). Line#1

str=f._______() Line#2

L=str.split()

count_char=0

for i in L:

count_char=count_char+len(i)

print(count_char)

f.close()

fl= open("Book.txt", "a")

name = input("Enter a book name") =

_____________#Line3

_____________ #Line4

a)Fill the blank in Linel so that the file will be opened.

b) In which mode file "Book.txt" will be opened in Linel c) Write the function in Line2 to read first 20 characters from the file "Book.txt"

d) Write the statement in Line3 to write the book name entered by the user into the

file "Book.txt"

e) Write the statement in Line4 to close the file "Book.txt" which is opened in "a" mode.

f) Write the position of file pointer when the file is opened in append mode

Answered by ankitbosch21
9

Answer: Please find the attached java program file for the solution.

Attachments:
Similar questions