Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <utility>
- using namespace std;
- int hoge(int a, int b) {
- int sum = 0;
- if (a > b) swap(a, b);
- for (int i = a; i <= b; i++) {
- int mul = 1;
- for (int j = 0; j < i; j++) mul *= i;
- sum += mul;
- }
- return sum;
- }
- int main() {
- cout << hoge(2, 5) << endl;
- cout << hoge(5, 2) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement