View difference between Paste ID: G99JfrH4 and SZEgHy9S
SHOW: | | - or go back to the newest paste.
1
#include <iostream>
2
#include <cmath>
3
#include <string>
4
5
6-
void UnosBroja( std::string &s, std::string r, int &n )
6+
void UnosBroja( std::string &s, std::string &r, int &n )
7
{
8
    std::cout<<s;
9
10
    for (;;)
11
    {
12
        std::cin>>n;
13
        if (std::cin) break;
14
        std::cout<<s;
15
        std::cout<<r;
16
       std::cin.clear();
17
       std::cin.ignore(1000, '\n');
18
19
20
    }
21
}
22
23
24
int main()
25
{
26
27
int n;
28
double x;
29
30
std::string s="Unesi prvi broj: ";
31
std::string r="Neispravan unos! \n";
32
33
UnosBroja(s,r,n);
34
35
std::cout<< "Unesi realan broj x:\n";
36
std::cin>>x;
37
std::cout<< "Stepen x^n je: " << pow(x,n) << std::endl;
38
39
40
return 0;
41
}