Untitled
unknown
c_cpp
8 months ago
736 B
1
Indexable
Never
#include <iostream> using namespace std; int sum(int a, int b) { return a + b; } int dif(int a, int b) { return a - b; } int mul(int a, int b) { return a * b; } int divi(int a, int b) { return a / b; } int step(int a, int b) { int i = 0; int count = 1; while (i < b) { count *= a; i++; } return count; } int main() { int a, b; char c; cin >> a >> c >> b; if (c == '+') { cout << sum(a, b); } if (c == '-') { cout << dif(a, b); } if (c == '*') { cout << mul(a, b); } if (c == '/') { cout << divi(a, b); } if (c == '^') { cout << step(a, b); } }
Leave a Comment