Are Integers Created Equally?
by CodeChum Admin
It's time to find out if something is true or false. Let's test your capabilities by creating a program that checks if two integers are equal!
Instructions:
Input two integers in one line.
Print the two integers in one line, separate them with a space.
Print a string message on a new line, "Equal" if both integers are equal
String Slicing
Given two strings
Check Whether the input string includes the substring using if condition and includes().
if the input string includes the substring then, find the index of the substring in the input string, using the indexof() and store the index in a variable.
slice the input string, using the slice() form index to the length of the input string and store in the variable slicedString. console the variable sliceString.
If the input string doesn't include the substring then else console the input string.
Given an M X N integer matrix, write a program to
-Find all zeros and replace them with the sum of their neighboring elements
-After replacing the zeros, set all other elements in the corresponding row and column with zeros
(excluding the elements which we previously zeros)
Note: consider the upper, lower, right and left elements as neighboring elements
Input
The first line of input is two space-separated M and N
The next M lines of input contain N space-separated integers
Output
The output should be an M X N matrix
SampleInput1:
3 3
1 2 3
4 0 2
1 1 8
Sample Output1:
1 0 3
0 9 0
1 0 8
SampleInput2:
4 5
4 8 0 0 0
4 7 0 9 7
5 5 6 9 8
7 4 3 6 7
SampleOutput2:
0 0 8 9 7
0 0 22 0 0
5 5 0 0 0
7 4 0 0 0
You are given a list of prices, where price [ i ] is the price of a given stock on the i th day
Write a program to print the maximum profit by choosing a single day to buy a stock and choosing a different day in the future to sell that stock
If there is no profit that can be achived return 0
Input:
The input is a single line containing space - separated integers
output:
The output should be a an integer
sample Input1:
7 1 5 3 6 4
sampleoutput1:
5
sampleinput2:
1 11 13 21 19
sample output2:
20
Write a program
Input: 5,3,3; Output: 5,15,45
Difference between c++ and c
Create a class that captures airline tickets. Each ticket lists the departure and arrival cities, a flight number, and a seat assignment. A seat assignment has both a row and a letter for the seat within the row (such as 12F). Make two examples of tickets?
Write a program in C++ that stores the numerator and denominator of two numbers infraction, after adding them the result is also stored into fraction format. Use structure fraction to store these numbers and their result (Bothnumeratoranddenominatorshouldbeof type int).
Write a programming C++ that calculates the number of possible arrangements for any number of guests and any number of chairs. (Assume there will never be fewer guests than chairs). A simple for loop should do it. for example the possible arrangement of six guests in four chairs is 360.
Given a space-separted list of integers as input, write a program to add the elements in the given range and print their sum
You will be given M multiple range queries,where
You should print the sum of numbers that belong to the corresponding range
note: while checking if the number belongs to a range,including the string and numbers of range as well
Input
The first line of input is space-separated integers
The secondline of input is a positive integers M denoting the number of queries
The next M line contain two space-separated integer
Output:
The output should be M line printing the sum of each includes range
sample input 1:
1 2 2 3 3 3 4 5 6
2
sampleInput2:
6 6 14 20 8 -2 2 -3
4
1 2
2 5
3 6
0 4
sampleOutput:
2
2
12
2