TheRasVa

Задача 4,2

Mar 21st, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. // Задача 4,2.cpp: определяет точку входа для консольного приложения.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using namespace std;
  7.  
  8.  
  9. double power(int a, int b)
  10. {
  11.     int i = 1;
  12.     double c = a;
  13.     if (b != 0)
  14.     {
  15.         while (i < b)
  16.         {
  17.             i++;
  18.             c = c*a;
  19.         }
  20.         return c;
  21.     } else return 1;
  22. }
  23.  
  24.  
  25. int main()
  26. {
  27.     double a, b;
  28.     setlocale(LC_ALL, "russian");
  29.     cin >> a >> b;
  30.     cout << power(a, b) << endl;
  31.     system("pause");
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment