#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
 
struct Color
{
	string  name;
	int     r;
	int     g;
	int     b;
	Color * next;
 
	Color () : name (""), r(0), g (0), b (0), next (nullptr)
	{}
 
	Color(string name0, int r0, int g0, int b0) 
		: name (name0), r(r0), g(g0), b(b0), next(nullptr)
	{ } 
 
};
 
Color * first = nullptr;
 
void insertFirst (string name0, int r0, int g0, int b0)
{
	Color * p = new Color (name0, r0, g0, b0);
	p->next = first;
	first = p; 
}
 
void insertLast(string name0, int r0, int g0, int b0)
{
	Color * p = new Color (name0, r0, g0, b0);
	p->next = nullptr;
	if (first == nullptr)
		first = p;
	else 
	{
		Color * t = first;
		while (t->next != nullptr)
		{
			t = t->next;
		}
		t->next = p;
	}
}
 
void print()
{
	cout << "seznam" << endl;
	Color * u = first;
	while (u != nullptr)
	{
		cout << u->name << ":"
			<< u->r << ":"
			<< u->g << ":"
			<< u->b << endl;
		u = u->next;
	}
}
 
int main()
{
	insertFirst ("Modra", 0, 0, 255);
	insertLast  ("Cervena", 255, 0, 0);
	insertFirst ("Zelena", 0, 255, 0);
	print ();
	system ("pause");
    return 0;
}
 
seznam2017b.txt · Last modified: 2017/11/14 12:37 by 147.32.8.110
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki