Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Rotate Matrix Rings

Given a matrix of order M*N and a value K, write a program to rotate each ring of the matrix clockwise by K elements. If in any ring has less than or equal to K elements, then don’t rotate that ring.


The first line of input will be two space-separated integers, denoting the M and N.

The next M lines will contain N space-separated integers.

The next line will contain an integer, denoting K.


The output should be M*N matrix by rotating the matrix by K elements.


For ex, if the given M and N are 4 and 4 respectively. If the matrix elements are

1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

If the given K is 3. Rotate each ring of the matrix by 3 elements.

In the above matrix, the elements (1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5) is a ring, similarly, the elements (6, 7, 11, 10) will make a ring.

Therefore, by rotating each ring in clockwise direction by 3 elements will give (13, 9, 5, 1, 2, 3, 4, 8, 12, 16, 15, 14) and (10, 6, 7, 11). So output is

13 9 5 1
14 7 11 2
15 6 10 3
16 12 8 4






Write a complete c++ program code which can multiply any two matrices. The two matrices must be any size. The elements of the two matrices is read from a file ex:matrix.dat. The result will be kept in a separate file call ex:matrix.res. Your program must be able to check whether the multiplication of the matrix can be done. show how to create a matrix.dat file so that it can read the file.


Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.


Input

The input will be a single line containing a string.


Output

The output should contain the sum and average of the numbers that appear in the string.

Note: Round the average value to two decimal places.


Explanation

For example, if the given string is "I am 25 years and 10 months old", the numbers are 25, 10. Your code should print the sum of the numbers(35) and the average of the numbers(17.5) in the new line.


Input 1:-

I am 25 years and 10 months old

Output 1:-

35

17.5


Input 2:-

Tech Foundation 35567

Output 2:-

35567

35567.0


We want given both inputs they can get both outputs we code was run one by one input and output


Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.


Input:-

The input will be a single line containing a string.


Output:-

The output should contain the sum and average of the digits of all numbers that appear in the string.

Note:- Round the average value to two decimal places.


Explanation:-

For example, if the given string is "I am 25 years and 10 months old", the digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line.


Input 1:-

I am 25 years and 10 months old

Output 1:-

8

2.0


Input 2:-

Tech Foundation 35567

Output 2:-

26

5.2


Input 3:-

Anjali25 is python4 Expert

Output 3:-

11

3.67


When we give three Inputs one by one they can give exact three Outputs must be come when code can be executed


Write a C++ program to calculate time dilation (t) in motion, when the speed of the moving objects (v) is given by the user. The given below is the equation to calculate the time dilation.

t = t0 /squreroot 1-v2/c2

v = speed of the moving object, c = 15000 ms-1(speed of light), and t0 = 75 s (time in observers own frame of reference)

·      User may insert a speed of the moving objects (v) above 60 ms-1 and below 75 ms-1 as the highest Speed.

·      Consider the speed of light (c) as a constant value.

·      Then the program should calculate the time dilation (t) for each speed of the moving object until the speed becomes 59 ms-1.

·      Use the necessary header files to do the calculation.



output

Enter the speed of the object :67

67 8.66034

66 8.66034

65 8.66034

64 8.66033

63 8.66033

62 8.66033

61 8.66033

60 8.66032


Given a string, write a program to print a secret message that replaces characters with numbers 'a' with 1, 'b' with 2, ..., 'z' with 26 where characters are separated by '-'.


Note: You need to replace both uppercase and lowercase characters. You can ignore replacing all characters that are not letters.


Input:-

The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).


Output:-

The output should be a single line containing the secret message. All characters in the output should be in lower case.


For Example -

Input 1:-

python


Output 1:-

16-25-20-8-15-14


Input 2:-

Foundations

Output 2:-

6-15-21-14-4-1-20-9-15-14-19


The general greedy method for the Knapsack problem first sorts the objects by some rule, and then puts the items into the knapsack according to this order subject to the capacity constraint. Consider the following three ordering rules: (a) Sort by size in increasing order. (b) Sort by profit in decreasing order. (c) Sort by profit/size in decreasing order. For each of the three above rules, give an instance to show that the approximation ratio of the greedy method using such rule can be arbitrarily large. 


Write a function-oriented program that calculates the sum of the sequence number from 1 to n. Thus, if the input is 5, the output should be 15 because: 1 + 2 + 3 + 4 + 5 = 15


Write a function-oriented program to convert the input dollar(s) into its equivalent peso. Assume that one dollar is equivalent to 53.80 pesos.


Write a function-oriented program that scans a number n and then
output the sum of the powers from 1 to n. Thus, if the input is 3, the output should be 14
because: 11
+ 22
+ 33
= 1 + 4 + 9 = 14
LATEST TUTORIALS
APPROVED BY CLIENTS