Advertisement
amermo

TP T-4 Z4

Mar 24th, 2015
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. template <typename NumerickiTip>
  5. void UnosBroja(std::string s1, std::string s2, NumerickiTip &n)
  6. {
  7.     std::cout << s1;
  8.     while(!(std::cin >> n) || std::cin.peek() != '\n')
  9.     {
  10.         std::cout << s2;
  11.         std::cin.clear();
  12.         std::cin.ignore(10000, '\n');
  13.         std::cout << s1;
  14.     }
  15. }
  16.  
  17. int main()
  18. {
  19.     double x;
  20.     int n;
  21.     UnosBroja("Unesi prvi broj: ", "Neispravan unos!\n", x);
  22.     UnosBroja("Unesi drugi broj: ", "Neispravan unos!\n", n);
  23.     std::cout << pow(x, n);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement