Example #1
0
int main(){
ifstream dat("zivotinje.txt");
if (!dat)
{
	cerr <<"Pogreska";
}
string l;

rjecnik f;
while (getline(dat,l,'\t'))
{
	stringstream s_l(l);
	Zivotinja* r = new Zivotinja;
	s_l >> r->broj;
	s_l.ignore();
	getline(dat,r->naziv);
	f.insert(r->broj,r);
}

f.search(5);
f.remove(5);
f.search(5);

dat.close();
system("pause");
cout << endl;
return 0;
}
Example #2
0
void number_partition::multinomial(base &res, INT f_v)
{
	base a, b, c;
	INT i, n, m;
	
	n = s_l();
	a.factorial(n);
#if 0
	if (f_v) {
		cout << "multinomial() factorial(" << n << ")=" << a << endl;
		}
#endif
	b.m_i_i(1);
	for (i = 1; i <= n; i++) {
		m = s_i(i - 1);
		if (m == 0)
			continue;
		c.factorial(i);
		c.power_int(m);
		b *= c;
		}
	a.integral_division_exact(b, res); 
	if (f_v) {
		cout << "multinomial(" << *this << ") = " << res << endl;
		}
}
Example #3
0
INT number_partition::nb_parts()
{
	INT i, n, s = 0;
	
	n = s_l();
	for (i = 0; i < n; i++) {
		// cout << "number_partition::nb_parts() i=" << i << ", s_i=" << s_i(i) << endl;
		s += s_i(i);
		}
	return s;
}
Example #4
0
INT unipoly::degree()
{
	INT l = s_l();
	INT i;
	
	for (i = l - 1; i >= 0; i--) {
		if (!s_i(i).is_zero())
			return i;
		}
	return 0;
}
Example #5
0
void number_partition::type(number_partition &q)
{
	INT s, i, n, a;
	
	s = nb_parts();
	q.allocate_number_partition();
	q.m_l(s);
	n = s_l();
	for (i = 0; i < n; i++) {
		a = s_i(i);
		if (a)
			q.s_i(a - 1)++;
		}
}
Example #6
0
INT number_partition::sum_of_decreased_parts()
{
	INT i, n, s;
	
	s = 0;
	if (s_type() != PARTITION_TYPE_EXPONENT) {
		cout << "number_partition::sum_of_decreased_parts() not of type exponent\n";
		exit(1);
		}
	n = s_l();
	for (i = 2; i <= n; i++) {
		s += s_i(i - 1) * (i - 1);
		}
	return s;
}
Example #7
0
void unipoly::negate_to(base &x)
{
	unipoly px;
	INT i, l;
	
	if (s_kind() != UNIPOLY) {
		cout << "unipoly::negate_to() this is not a unipoly\n";
		exit(1);
		}
	l = s_l();
	px.m_l(l);
	for (i = 0; i < l; i++) {
		s_i(i).negate_to(px.s_i(i));
		}
	x.swap(px);
}
Example #8
0
void number_partition::conjugate()
{
	Vector q;
	INT i, ii = 0, n, s, a;
	
	n = s_l();
	q.m_l_n(n);
	s = nb_parts();
	// cout << "number_partition::conjugate() s=" << s << endl;
	for (i = 1; i <= n; i++) {
		a = s_i(i - 1);
		if (a) {
			q.m_ii(s - 1, i - ii);
			// cout << "partition::conjugate() q[" << s - 1 << "] = " << i - ii << endl;
			ii = i;
			s -= a;
			}
		}
	q.swap(s_self());
}