GitHub PullRequestReviewCommentEvent at 2014-03-31 19:53:01
Repository: pamsi2014
Actor: eMaerthin
Payload: {"comment":{"url":"https://api.github.com/repos/eMaerthin/pamsi2014/pulls/comments/11133412","id":11133412,"diff_hunk":"@@ -0,0 +1,290 @@\n+#include <iostream>\n+#include <stack>\n+#include <array>\n+#include <queue>\n+#include <ctime>\n+#include <cmath>\n+#include <string>\n+\n+using namespace std;\n+\n+template <class T>\n+T rozwinieciePi(int ktory, int precyzja) {\n+\tlong double pi = 0;\n+\tlong double tmp = 0;\n+\tint n = 0;\n+\tdo {\n+\t\ttmp = pow((long double)-1,(long double)n)/(2*n+1);\n+\t\tpi = pi + tmp;\n+\t\tn++;\n+\t} while (n < 5000);\n+\tpi = pi * 4;\n+\tchar* tablica = new char[precyzja + 1]; //bo wpisywana jest kropka\n+\tgcvt(pi, precyzja, tablica);\n+\t//cout.precision(precyzja);\n+\t//cout << \"\\t\" << pi << endl;\n+\tif(ktory >= 1)\n+\t\treturn (int)tablica[ktory + 1] - 48;\n+\telse if(ktory == 0)\n+\t\treturn (int)tablica[ktory] - 48;\n+}\n+/**\n+*\tKlasa Stosu\n+*/\n+template <class T> //kostruktor i desktruktor\n+class Stos {\n+private:\n+\tstack <T> stos;\n+public:\n+\tvoid dodawanieElementow();\n+\tvoid wyswietlanie();\n+\tbool wyszukiwanieElementow();\n+\tvoid usuwanieElementow();\n+};\n+\n+template <class T>\n+void Stos <T>::dodawanieElementow() {\n+\tT el;\n+\tcout << \"Jaki element chcesz wprowadzic?\\n\";\n+\tcin >> el;\n+\tstos.push(el);\n+}\n+\n+template <class T>\n+void Stos <T>::wyswietlanie() {\t\t\t//DA SIE PEWNIE LADNIEJ\n+\tcout << \"\\nZawartosc stosu:\\n\";\n+\tstack <T> tmp;\n+\tT tmpel;\n+\twhile(!stos.empty()) {\n+\t\tcout << stos.top() << endl;\n+\t\ttmpel = stos.top();\n+\t\tstos.pop();\n+\t\ttmp.push(tmpel);\n+\t}\n+\twhile(!tmp.empty()){\n+\t\ttmpel = tmp.top();\n+\t\ttmp.pop();\n+\t\tstos.push(tmpel);\n+\t}\n+}\n+\n+template <class T>\n+void Stos <T>::usuwanieElementow() {\n+\tstos.pop();\n+}\n+\n+template <class T>\n+bool Stos <T>::wyszukiwanieElementow() {\n+\tT el;\n+\tcout << \"Jaki element wyszukac?\\n\";\n+\tcin >> el;\n+\tfor(int i = 0; i < stos.size(); i++) {\n+\t\tif((stos.top() - i) == el) {\n+\t\t\tcout << \"Element znajduje sie w stosie\"\n+\t\t\t\t<< \"\\njest to \" << i << \" element od gory\\n\";\n+\t\t\treturn true;\n+\t\t}\n+\t}\n+\tcout << \"Nie ma takiego elementu na stosie\\n\";\n+\treturn false;\n+}\n+\n+/**\n+*\tKlasa Kopca\n+*/\n+template <class T>\n+class Kopiec {\n+private:\n+\tint rozmiar;\n+\tint poziomy;\n+\tT* kopiec;\n+public:\n+\tKopiec(): rozmiar(0), poziomy(0) {};\n+\tKopiec(int rozm): rozmiar(rozm), poziomy(sqrt((double)rozm) + 1) {\n+\t\tkopiec = new T [rozmiar];\n+\t};\n+\t~Kopiec();\n+\tvoid deklaracjaTablicy();\n+\tvoid przywracanieKopca();\n+\tvoid wyswietlanieKopca();\n+\tvoid usuwanieSzczytu();\n+\tvoid kopcowanie(T a);\n+};\n+\n+template <class T>\n+void Kopiec <T>::deklaracjaTablicy() {\n+\tT random;\n+\tfor(int i = 0; i < rozmiar; i++) {\n+\t\tkopiec[i] = rozwinieciePi <T> (i,rozmiar);\n+\t}\n+\tfor(int i = 0; i < rozmiar; i++) {\n+\t\tcout << kopiec[i] << \"  \";\n+\t}\n+\tcout << endl;cout << endl;\n+}\n+\n+///kopiec mozna zapisac w tablicy i wtedy:\n+// rodzic [i]\n+// dzieci [2i+1] oraz [2i+2]\n+template <class T>\n+void Kopiec <T>::wyswietlanieKopca() {\n+\tint poziom = 0;\n+\tint stala = 1;\n+\tint wysrodkowanie = -1;\n+\tfor(int i = 0; i < rozmiar; i++) {\n+\t\tif(i == stala) {\n+\t\t\tpoziom++;\n+\t\t\tstala = stala + pow(2,(double)poziom);\n+\t\t\tcout << endl;\n+\t\t}\n+\tcout << kopiec[i] << \" \";\n+\t}\n+\t/*//Druga opcja to z przesuwaniem bitowym:\n+\tcout << \"\\n\\n\";\n+\tint spr = 1;\n+\tint n = rozmiar;\n+\tfor(int i = 0; i < poziom + 1; i++) {\n+\t\tspr = 1 << i;\n+\t\tfor(int k = 0; k < pow((double)2, (double)i); k++) {\n+\t\t\tspr += k;\n+\t\t\tcout << kopiec[rozmiar - n] << \"\\t\";\n+\t\t\tn--;\n+\t\t\tif(n == 0) break;\n+\t\t}\n+\t\tcout << endl;\n+\t}*/\n+}\n+\n+template <class T>\n+void Kopiec <T>::przywracanieKopca() {\n+\tfor(int k = 0; k < poziomy; k++)\n+\t\tfor(int i = 0; i < rozmiar; i++)\n+\t\t\tkopcowanie(i);\n+}\n+\n+template <class T>\n+void Kopiec <T>::kopcowanie(T a) {\n+\tint lewy, prawy, rodzic;\n+\tif(a != 0) {\n+\t\tlewy = 2 * a + 1;\n+\t\tprawy = 2 * a + 2;\n+\t\trodzic = a;\n+\t}\n+\telse {\n+\t\tlewy = 1;\n+\t\tprawy = 2;\n+\t\trodzic = a;\n+\t}\n+\tif (lewy <= rozmiar && kopiec[lewy] > kopiec[rodzic]) {\n+\t\trodzic = lewy;\n+\t}\n+\tif(prawy <= rozmiar && kopiec[prawy] > kopiec[rodzic]) {\n+\t\trodzic = prawy;\n+\t}\n+\tif(rodzic != a) {\n+\t\tT tmp = kopiec[a];\n+\t\tkopiec[a] = kopiec[rodzic];\n+\t\tkopiec[rodzic] = tmp;\n+\t\tkopcowanie(rodzic);\n+\t}\n+}\n+\n+template <class T>\t\t\t\t//O CO CHODZI? CZY O TO?\n+void Kopiec <T>::usuwanieSzczytu(){\t\t\t\n+\trozmiar--;\n+\tfor(int i = 0; i < rozmiar; i++) {\n+\t\tkopiec[i] = kopiec[i+1];\n+\t}\n+\tpoziomy = sqrt((double)rozmiar) + 1;\n+\tprzywracanieKopca();\n+}\n+\n+template <class T>\n+class Kolejka {\n+\tqueue <T> kolejka;\n+public:\n+\t//Kolejka();\n+\t//~Kolejka();\n+\tvoid dodawanie(T el);\t\t//elementow na koniec kolejki\n+\tT pobieranie();\t\t\t\t//elementow z poczatku kolejki(usuwanie)\n+\tvoid wyswietlanieDlugosci();//kolejki\n+\tvoid wyswietlanie();\t\t//zawartosci kolejki\n+};\n+\n+template <class T>\n+void Kolejka <T>::dodawanie(T el) {\n+\tkolejka.push(el);\n+}\n+\n+template <class T>\n+void Kolejka <T>::wyswietlanie() {\n+\tcout << \"\\nZawartosc kolejki:\\n\";\n+\tqueue <T> tmp;\n+\tT tmpel;\n+\twhile(!kolejka.empty()) {\n+\t\tcout << kolejka.front() << endl;\n+\t\ttmpel = kolejka.front();\n+\t\tkolejka.pop();\n+\t\ttmp.push(tmpel);\n+\t}\n+\twhile(!tmp.empty()){\n+\t\ttmpel = tmp.front();\n+\t\ttmp.pop();\n+\t\tkolejka.push(tmpel);\n+\t}\n+}\n+\n+template <class T>\n+void Kolejka <T>::wyswietlanieDlugosci() {\n+\tcout << \"\\nDlugosc kolejki: \" << kolejka.size() << endl;\n+}\n+\n+template <class T>\t\t\t\t//Ma usuwac tez pierwszy? Czy tylko wyswietlac?\n+T Kolejka <T>::pobieranie() {\n+\tT el = kolejka.front();\n+\tkolejka.pop();","path":"Monika_Strachowska/Program_3/Program_3/main.cpp","position":245,"original_position":245,"commit_id":"7e2a45568408015d09f0487aefb6f0efa7efaad0","original_commit_id":"7e2a45568408015d09f0487aefb6f0efa7efaad0","user":{"login":"eMaerthin","id":4299430,"avatar_url":"https://avatars.githubusercontent.com/u/4299430?","gravatar_id":"dbeaea3e7932e7224119b4e37068c84f","url":"https://api.github.com/users/eMaerthin","html_url":"https://github.com/eMaerthin","followers_url":"https://api.github.com/users/eMaerthin/followers","following_url":"https://api.github.com/users/eMaerthin/following{/other_user}","gists_url":"https://api.github.com/users/eMaerthin/gists{/gist_id}","starred_url":"https://api.github.com/users/eMaerthin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eMaerthin/subscriptions","organizations_url":"https://api.github.com/users/eMaerthin/orgs","repos_url":"https://api.github.com/users/eMaerthin/repos","events_url":"https://api.github.com/users/eMaerthin/events{/privacy}","received_events_url":"https://api.github.com/users/eMaerthin/received_events","type":"User","site_admin":false},"body":"nie sprawdza Pani, czy coś w ogóle znajduje się w kolejce...","created_at":"2014-03-31T19:53:01Z","updated_at":"2014-03-31T19:53:01Z","html_url":"https://github.com/eMaerthin/pamsi2014/pull/58#discussion_r11133412","pull_request_url":"https://api.github.com/repos/eMaerthin/pamsi2014/pulls/58","_links":{"self":{"href":"https://api.github.com/repos/eMaerthin/pamsi2014/pulls/comments/11133412"},"html":{"href":"https://github.com/eMaerthin/pamsi2014/pull/58#discussion_r11133412"},"pull_request":{"href":"https://api.github.com/repos/eMaerthin/pamsi2014/pulls/58"}}}}