Anonymous
Given a String with numbers and operators. Perform the operation on the numbers in their respective order. Operator precedence need not be considered. The input string will have the numbers followed by the operators.
Input: "12345 * + - + " Result: 6 [Explanation: 1 * 2 + 3 - 4 + 5 = 6] Input: "374291 - - * + -" Result: -8 [Explanation: 3 - 7 - 4 * 2 + 9 - 1 = -8]
Guys can you help
Anonymous
s = list(input().split())
num = []
e = []
for i in s:
if i.isdigit():
num.append(i)
else:
e.append(i)
num = num[::-1]
result = 0
final = 0
for i in e:
a = int(num.pop())
b = int(num.pop())
if i == '*':
final = a * b
num.append(final)
elif i == '/':
final = a / b
num.append(final)
elif i == '-':
final = a - b
num.append(final)
else:
final = a+b
num.append(final)
print(num[-1])
its.ham
Write a C ++ program that contain the following functions Function called Average that returns the average of even numbers in the array Function called Shift that Shift the array right one elementExIf the array is 2,3,8,1,0,6,3, after shifting the array will be 9,2,3,8,1,0,6,3,4,! • Function called Replace that replace elements of the array by entered value Ex. If the array is 1,5,2,8,1,6,1,5,9, and the user enter 1 and 20 then the array will be 20,52,8,20,6,20,594. Function called is Armstrong that take an integer array and Boolean array and fill the boolean array by true or false if the corresponding number is Armstrong or not Hint: Armstrong number is a number that is equal to the sum of cubes of its digits(unspecified number of digits)For example 153 is Armstrong numbers because 1^ * 1^ * 1+5*5*5+3*3*3=153 . if the array is \ 153,12,1259,3\ 0\ , boolean array will be \ 3,0,0,3\ In the main define an array called numbers with size 10 and fill it by the user then call Average and Shift function Enter 2 values and Replace function Define boolean array called Armstrong and call isArmstrong function finally print the array after calling functions and print boolean array
@𝑺𝒐𝒃𝒌𝒂
Hi everybody.
I'm trying to write a predicate function that test if a number is perfect.
When I call it, main function return a nonzero value and I get nothing at output. What's wrong?
#include <iostream>
using namespace std;
bool isPerfect (int);
int main()
{
cout<<isPerfect(28);
return 0;
}
bool isPerfect (int number)
{
int sum = 0;
for(int i = 0; i < number/2; i++)
{
if(number%i == 0)
sum += i;
}
return number == sum;
}
omar👷♂️
Write a program that reads from the user a string matrix with 3×3 dimensions, the program has to search for a name that is given by the user when the name is found print found else print not found? C++.
Sankalp
Create a C++ base class Shape. Derive three different classes Circle, Sphere and Cylinder from shape
class. Write a C++ program to calculate area of Circle, Sphere and Cylinder. (Use pure virtual function).
Sankalp
Create a C++ base class Media. Derive two different classes from it, class NewsPaper with data members N Name, N Editor, N_Price, No of Pages and class Magazine with data members M Name, M_Editor. M_Price. Write a C++ program to accept and display information of both NewsPaper and Magazine. (Use pure virtual function)
Anonymous
Just think of binary trees with 3 nodes...with 1 as a root, there are different trees like
1left2left3 1left2right3 1left2-1right3 1right3left2 1right3right2 1left3left2 1left3right2 1left3-1right2 1right2left3 1right2right3... so 10 in all.
With2 as root, 10 more and with 3 as root 10 more. So 30 in all which (2*3)!/(3+1)!