Advertisement
cd62131

hoge

Jan 30th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <utility>
  3. using namespace std;
  4. int hoge(int a, int b) {
  5.   int sum = 0;
  6.   if (a > b) swap(a, b);
  7.   for (int i = a; i <= b; i++) {
  8.     int mul = 1;
  9.     for (int j = 0; j < i; j++) mul *= i;
  10.     sum += mul;
  11.   }
  12.   return sum;
  13. }
  14. int main() {
  15.   cout << hoge(2, 5) << endl;
  16.   cout << hoge(5, 2) << endl;
  17.   return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement