#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
struct User1 {
string Nome;
int NxZ;
int hNX2;
int kJXU;
};
int CalcJnxU(User1 x) { //x é do tipo User1 e é uma variável local desta função
int Resultado;
srand(time(0)) ;
Resultado = x.hNX2 + (rand() % 4);
return Resultado;
}
int main() {
User1 x; //este x só existe aqui no Main, mas seu valor pode ser passado p/ outras funções
x.Nome = "nome1";
x.NxZ = 20;
x.hNX2 = 2;
x.kJXU = 2;
cout << CalcJnxU(x);
return 0;
}
//https://pt.stackoverflow.com/q/41864/101
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPGN0aW1lPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCBVc2VyMSB7CiAgICBzdHJpbmcgTm9tZTsKICAgIGludCBOeFo7CiAgICBpbnQgaE5YMjsKICAgIGludCBrSlhVOwp9OwoKaW50IENhbGNKbnhVKFVzZXIxIHgpIHsgLy94IMOpIGRvIHRpcG8gVXNlcjEgZSDDqSB1bWEgdmFyacOhdmVsIGxvY2FsIGRlc3RhIGZ1bsOnw6NvCiAgICBpbnQgUmVzdWx0YWRvOwogICAgc3JhbmQodGltZSgwKSkgOwogICAgUmVzdWx0YWRvID0geC5oTlgyICsgKHJhbmQoKSAlIDQpOwogICAgcmV0dXJuIFJlc3VsdGFkbzsKfQoKaW50IG1haW4oKSB7CiAgICBVc2VyMSB4OyAvL2VzdGUgeCBzw7MgZXhpc3RlIGFxdWkgbm8gTWFpbiwgbWFzIHNldSB2YWxvciBwb2RlIHNlciBwYXNzYWRvIHAvIG91dHJhcyBmdW7Dp8O1ZXMKICAgIHguTm9tZSA9ICJub21lMSI7CiAgICB4Lk54WiA9IDIwOwogICAgeC5oTlgyID0gMjsKICAgIHgua0pYVSA9IDI7CiAgICBjb3V0IDw8IENhbGNKbnhVKHgpOwoJcmV0dXJuIDA7Cn0KCi8vaHR0cHM6Ly9wdC5zdGFja292ZXJmbG93LmNvbS9xLzQxODY0LzEwMQ==