//неправильно
if (a >= 0 && b >= 0)
{
sum = a + b;
}
else
//правильно:
if (a == b)
{
return a;
}
else
public int GetSum(int a, int b) {
int min = Math.Min(a, b),
max = Math.Max(a, b),
sum = max;
for (int i = min; i < max; ++i) sum += i;
return sum;
}
from urllib.parse import urlencode
import quopri
# Туда
args = {'a':1, 'en': 'hello', 'rus': u'привет'}
url = urlencode(args, encoding='utf-8')
print(url)
# а теперь обратно
q = '%D0%BF%D1%80%D0%B8%D0%B2%D0%B5%D1%82'
q = bytes(q.replace('%', '='), 'UTF-8')
print(q)
b = quopri.decodestring(q)
print(b.decode('UTF-8'))
if(places != nullptr){
...
places[count_places - 1] = p; //здесь копируем
} else{
places = &p; //а здесь мы разыменовываем, а нужно делать new[]
//а на следующем вызове UB из-за delete[], потому что places не выделялось через new[]
}
if(places != nullptr){
...
} else{
count_places = 1;
places = new Patient[1];
places[0] = p;
}
#include <iostream>
using namespace std;
class Zespolona
{
public:
Zespolona(double _a = 0, double _b = 0) :a(_a), b(_b) {}
void print() {cout << a << " " << b << endl;}
private:
double a, b;
friend Zespolona operator+(const Zespolona& l, const Zespolona& r);
};
Zespolona operator+(const Zespolona& l, const Zespolona& r)
{
return Zespolona(l.a+r.a, l.b+r.b);
}
int main()
{
Zespolona one(1,2), two(3,4);
Zespolona three = one + two;
three.print();
system("pause");
return 0;
}
if(access(pathhtml, 0) == 0){ //проверяем на существование файл.