Advertisement
sellmmaahh

tut4-zad4

Jul 21st, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdexcept>
  3.  
  4.  
  5. template <typename Tip1>
  6. void UnosBroja (std::string s1, std::string s2, Tip1 &n)
  7. {
  8.  
  9.     std::cout<<s1;
  10.     std::cin>>n;
  11.     if ((!std::cin) || (std::cin.peek()!='\n'))  {
  12.            std::cout<<s2;
  13.        std::cin.clear();
  14.        std::cin.ignore(1000, '\n');
  15.        std::cin>>n;
  16.     }
  17. }
  18. int main () {
  19. double x; int n;
  20. UnosBroja("Unesite prvi broj: ", "Pogresan unos!",x);
  21. UnosBroja("Unesite drugi broj: ", "Pogresan unos!",n);
  22. double b(x);
  23. for (int i=2; i<=n; i++) {
  24.     x*=b;
  25. }
  26. std::cout<<"Rezultat: "<<x;
  27. return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement