Advertisement
Guest User

Main-ul

a guest
May 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <windows.h>
  4. #include "grafneorientat.h"
  5. #include <string.h>
  6.  
  7. using namespace std;
  8.  
  9. void introducere()
  10. {
  11. cout<<"=|===================================================================================================================|="<<endl;
  12. cout<<"=|= =|="<<endl;
  13. cout<<"=|= TEZA LA INFORMATICA =|="<<endl;
  14. cout<<"=|= -CLASA A XI-E- =|="<<endl;
  15. cout<<"=|= =|="<<endl;
  16. cout<<"=|= PROIECT REALIZAT DE :FARCAS VLAD SI ICHIM OCTAVIAN =|="<<endl;
  17. cout<<"=|= =|="<<endl;
  18. cout<<"=|= TEMA PROIECTULUI : GRAFURI NEORIENTATE =|="<<endl;
  19. cout<<"=|= =|="<<endl;
  20. cout<<"=|= PROFESOR : IVASC CORNELIA =|="<<endl;
  21. }
  22.  
  23. void meniu()
  24. {
  25. cout<<"=|= =|="<<endl;
  26. cout<<"=|= =|="<<endl;
  27. cout<<"=|= MENIU =|="<<endl;
  28. cout<<"=|= =|="<<endl;
  29. cout<<"=|= CITIRE / AFISARE =|="<<endl;
  30. cout<<"=|= =|="<<endl;
  31. cout<<"=|= 1.FUNCTIE PENTRU CITIREA UNUI GRAF.VETI CITI N,M SI MAI APOI M PERECHI DE FORMA (X,Y) REPREZENTAN =|="<<endl;
  32. cout<<"=|= NUMARUL DE NODURI , NUMARUL DE MUCHII SI RESPECTIV PERECHILE DE NODURI INTRE CARE EXISTA MUCHIE =|="<<endl;
  33. cout<<"=|= 2.FUNCTIE PENTRU AFISAREA UNUI GRAF.FUNCTIA VA AFISA MATRICEA DE ADIACENTA A GRAFULUI. =|="<<endl;
  34. cout<<"=|= =|="<<endl;
  35. cout<<"=|= ADAUGARE/STERGERE/VERIFICARE MUCHII =|="<<endl;
  36. cout<<"=|= =|="<<endl;
  37. cout<<"=|= VETI CITI OPERATIA APOI X SI Y IAR FUNCTIA VA =|="<<endl;
  38. cout<<"=|= =|="<<endl;
  39. cout<<"=|= 3.ADAUGA MUCHIE INTRE X SI Y RESPECTIV Y SI X. =|="<<endl;
  40. cout<<"=|= 4.STERGE MUCHIA DINTRE X SI Y RESPECTIV Y SI X. =|="<<endl;
  41. cout<<"=|= 5.VA AFISA MESAJUL 'DA' DACA EXISTA MUCHIE INTRE X SI Y SAU 'NU' IN CAZ CONTRAR. =|="<<endl;
  42. cout<<"=|= =|="<<endl;
  43. cout<<"=|= DFS/BFS =|="<<endl;
  44. cout<<"=|= =|="<<endl;
  45. cout<<"=|= 6.FUNCTIA VA AFISA VARFURILE VIZITATE IN URMA PARCURGERII IN ADANCIME(DFS). =|="<<endl;
  46. cout<<"=|= 7.FUNCTIA VA AFISA VARFURILE VIZITATE IN URMA PARCURGERII IN LATIME(BFS). =|="<<endl;
  47. cout<<"=|= =|="<<endl;
  48. cout<<"=|= VERIFICARE PROPRIETATI GRAF =|="<<endl;
  49. cout<<"=|= =|="<<endl;
  50. cout<<"=|= 8.VERIFICARE GRAF COMPLET.FUNCTIA VA AFISA 'DA' DACA GRAFUL ESTE COMPLET SI 'NU' IN CAZ CONTRAR. =|="<<endl;
  51. cout<<"=|= 9.VERIFICARE GRAF BIPARTIT.FUNCTIA VA AFISA 'DA' SI DOUA MULTIMI CARE FORMEAZA PARTITIA VARFURILOR SI =|="<<endl;
  52. cout<<"=|= 'NU' IN CAZ CONTRAR. =|="<<endl;
  53. cout<<"=|= 10.VERIFICARE GRAF CONEX.FUNCTIA VA AFISA MESAJUL 'DA' DACA GRAFUL ESTE CONEX SI 'NU' IN CAZ CONTRAR =|="<<endl;
  54. cout<<"=|= 11.VERIFICARE GRAF EULERIAN.FUNCTIA VA AFISA MESAJUL 'DA' URMAT DE UN VARFURILE UNUI CICLU EULERIAN SI =|="<<endl;
  55. cout<<"=|= 'NU' IN CAZ CONTRAR. =|="<<endl;
  56. cout<<"=|= 12.VERIFICARE GRAF PARTIAL.VETI CITI 2 GRAFURI IAR FUNCTIA VA AFISA MESAJUL 'DA' DACA PRIMUL GRAF ESTE =|="<<endl;
  57. cout<<"=|= GRAF PARTIAL AL CELUI DE-AL DOILEA GRAF SI NU IN CAZ CONTRAR. =|="<<endl;
  58. cout<<"=|= =|="<<endl;
  59. cout<<"=|= ALTE FUNCTII =|="<<endl;
  60. cout<<"=|= =|="<<endl;
  61. cout<<"=|= 13.NUMAR DE NODURI.FUNCTIA VA AFISA NUMARUL DE NODURI AL GRAFULUI. =|="<<endl;
  62. cout<<"=|= 14.GRAD NOD.VETI CITI OPERATIA APOI UN NOD X APARTINAND GRAFULUI IAR FUNCTIA VA AFISA GRADUL ACESTUIA. =|="<<endl;
  63. cout<<"=|= 15.COMPONENTE CONEXTE.FUNCTIA VA AFISA NUMARUL DE COMPONENTE CONEXE RESPECTIV ACESTEA. =|="<<endl;
  64. cout<<"=|= 16.NUMAR NODURI IZOLATE.FUNCTIA VA AFISA NUMARUL DE NODURI IZOLATE. =|="<<endl;
  65. cout<<"=|= 17.VERIFICARE CICLU EULERIAN.VETI CITI N APOI N NUMERE REPREZENTAND UN SIR DE NUMERE.FUNCTIA VA AFISA =|="<<endl;
  66. cout<<"=|= MESAJUL 'DA' DACA SIRUL POATE REPREZENTA UN CICLU EULERIAN SI 'NU' IN CAZ CONTRAR. =|="<<endl;
  67. cout<<"=|= 18.AFISARE GRADE NODURI.FUNCTIA VA AFISA FIECARE NOD AL GRAFULUI URMAT DE GRADUL SAU. =|="<<endl;
  68. cout<<"=|= 19.AFISARE MATRICE DRUMURI.FUNCTIA VA AFISA MATRICEA DRUMURILOR CORESPUNZATOARE GRAFULUI. =|="<<endl;
  69. cout<<"=|= 20.AFISARE LANT MINIM DE LA NODUL X LA NODUL Y.FUNCTIA VA AFISA LUNGIMEA LANTULUI URMAT =|="<<endl;
  70. cout<<"=|= DE NODURILE CARE IL FORMEAZA =|="<<endl;
  71. cout<<"=|= =|="<<endl;
  72. }
  73.  
  74. void altele()
  75. {
  76. cout<<"=|= =|="<<endl;
  77. cout<<"=|= COMENZI AJUTATOARE =|="<<endl;
  78. cout<<"=|= =|="<<endl;
  79. cout<<"=|= 'menu' PENTRU A AFISA DIN NOU MENIUL =|="<<endl;
  80. cout<<"=|= 'exit' PENTRU A IESI DIN APLICATIE =|="<<endl;
  81. }
  82.  
  83. void goodbye()
  84. {
  85. cout<<"=|===================================================================================================================|="<<endl;
  86. }
  87.  
  88. void comanda_gresita()
  89. {
  90. cout<<"=|= NU EXISTA ACEASTA COMANDA , MAI INCEARCA =|="<<endl;
  91. }
  92.  
  93. void menu()
  94. {
  95. GN G(3),Graf,G2,G1,G3;
  96. int rasp,op,x,y,v[100],mr;
  97. char comand[10];
  98. HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  99. SetConsoleTextAttribute(hConsole, 2);
  100. bool ok=1;
  101. int nr;
  102. introducere();
  103. meniu();
  104. altele();
  105. while(ok)
  106. {
  107. SetConsoleTextAttribute(hConsole, 2);
  108. cout<<"=|= CITESTE COMANDA : =|="<<endl;
  109. cout<<"=> ";
  110. SetConsoleTextAttribute(hConsole, 12);
  111. cin>>comand;
  112. SetConsoleTextAttribute(hConsole, 2);
  113. if(strcmp(comand,"menu")==0)
  114. {
  115. SetConsoleTextAttribute(hConsole, 2);
  116. meniu();
  117. }
  118. else if(strcmp(comand,"exit")==0)
  119. {
  120. SetConsoleTextAttribute(hConsole, 2);
  121. goodbye();
  122. ok=0;
  123. }
  124. else
  125. {
  126. nr=atol(comand);
  127. switch(nr)
  128. {
  129. case 1 :
  130. cout<<"=|= CITESTE N M SI APOI M PERECHI DE FORMA X Y =|="<<endl;
  131. SetConsoleTextAttribute(hConsole, 7);
  132. cin>>G1;
  133. break;
  134. case 2:
  135. if(G1.numar_noduri()==0)
  136. cout<<"GRAFUL NU EXISTA / NU ARE UN NUMAR DE NODURI DEFINIT"<<endl;
  137. else
  138. {
  139. cout<<"=|= MATRICEA DE ADIACENTA A GRAFULUI ESTE : =|="<<endl;
  140. SetConsoleTextAttribute(hConsole, 5);
  141. cout<<G1;
  142. }
  143. break;
  144. case 3:
  145. cout<<"=|= CITESTE X SI Y INSEMNAND NODURILE INTRE CARE VREI SA FACI O MUCHIE : =|="<<endl;
  146. cout<<"=> ";
  147. SetConsoleTextAttribute(hConsole, 3);
  148. cin>>x>>y;
  149. G1.set_muchie(x,y);
  150. break;
  151. case 4:
  152. cout<<"=|= CITESTE X SI Y INSEMNAND NODURILE INTRE CARE VREI SA STERGI MUCHIA : =|="<<endl;
  153. cout<<"=> ";
  154. SetConsoleTextAttribute(hConsole, 3);
  155. cin>>x>>y;
  156. G1.delete_muchie(x,y);
  157. break;
  158. case 5:
  159. cout<<"=|= CITESTE X SI Y INSEMNAND NODURILE INTRE CARE VREI SA VEZI DACA ESTE MUCHIE : =|="<<endl;
  160. cout<<"=> ";
  161. SetConsoleTextAttribute(hConsole, 3);
  162. cin>>x>>y;
  163. if(G1.verif_muchie(x,y))
  164. {
  165. SetConsoleTextAttribute(hConsole, 9);
  166. cout<<"DA"<<endl;
  167. }
  168. else
  169. {
  170. SetConsoleTextAttribute(hConsole, 4);
  171. cout<<"NU"<<endl;
  172. }
  173. break;
  174. case 6:
  175. cout<<"=|= PARCURGEREA NODURILOR IN ADANCIME DIN NODUL 1 : =|="<<endl;
  176. SetConsoleTextAttribute(hConsole, 9);
  177. G1.DFS(1);
  178. cout<<endl;
  179. break;
  180. case 7:
  181. cout<<"=|= PARCURGEREA NODURILOR IN LATIME DIN NODUL 1 : =|="<<endl;
  182. SetConsoleTextAttribute(hConsole, 9);
  183. G1.BFS(1);
  184. break;
  185. case 8:
  186. if(G1.graf_complet())
  187. {
  188. SetConsoleTextAttribute(hConsole, 9);
  189. cout<<"GRAFUL ESTE COMPLET"<<endl;
  190. }
  191. else
  192. {
  193. SetConsoleTextAttribute(hConsole, 4);
  194. cout<<"GRAFUL NU ESTE COMPLET"<<endl;
  195. }
  196. break;
  197. case 9:
  198. SetConsoleTextAttribute(hConsole, 7);
  199. G1.bipartit();
  200. break;
  201. case 10:
  202. if(G1.conex())
  203. {
  204. SetConsoleTextAttribute(hConsole, 9);
  205. cout<<"DA,GRAFUL ESTE CONEX"<<endl;
  206. }
  207. else
  208. {
  209. SetConsoleTextAttribute(hConsole, 4);
  210. cout<<"NU,GRAFUL NU ESTE CONEX"<<endl;
  211. }
  212. break;
  213. case 11:
  214. if(G1.euler())
  215. {
  216. SetConsoleTextAttribute(hConsole, 9);
  217. cout<<"DA"<<endl;
  218. G1.ciclu_eulerian(1);
  219. cout<<endl;
  220. }
  221. else
  222. {
  223. SetConsoleTextAttribute(hConsole, 4);
  224. cout<<"NU"<<endl;
  225. }
  226. break;
  227. case 12:
  228. cin>>G2>>G3;
  229. if(G2<G3)
  230. {
  231. SetConsoleTextAttribute(hConsole, 9);
  232. cout<<"DA,PRIMUL GRAF ESTE GRAF PARTIAL AL CELUI DE-AL DOILEA GRAF"<<endl;
  233. }
  234. else
  235. {
  236. SetConsoleTextAttribute(hConsole, 4);
  237. cout<<"NU,PRIMUL GRAF NU ESTE GRAF PARTIAL AL CELUI DE-AL DOILEA GRAF"<<endl;
  238. }
  239. break;
  240. case 13:
  241. SetConsoleTextAttribute(hConsole, 12);
  242. cout<<"GRAFUL ARE "<<G1.numar_noduri()<<" NODURI"<<endl;
  243. break;
  244. case 14:
  245. cin>>x;
  246. SetConsoleTextAttribute(hConsole, 13);
  247. cout<<"GRADUL NODULUI "<<x<<" ESTE "<<G1.grad(x)<<endl;
  248. break;
  249. case 15:
  250. G1.componente_conexe();
  251. break;
  252. case 16:
  253. SetConsoleTextAttribute(hConsole, 13);
  254. cout<<"NUMARUL NODURILOR IZOLATE DIN GRAF ESTE "<<G1.numar_noduri_izolate()<<endl;
  255. break;
  256. case 17:
  257. cin>>mr;
  258. for(int i=1; i<=mr; i++)
  259. cin>>v[i];
  260. if(G1.verif_ciclu_eulerian(v,mr))
  261. {
  262. SetConsoleTextAttribute(hConsole, 9);
  263. cout<<"DA,SIRUL REPREZINTA UN CICLU EULERIAN AL GRAFULUI CITIT"<<endl;
  264. }
  265. else
  266. {
  267. SetConsoleTextAttribute(hConsole, 4);
  268. cout<<"NU,SIRUL NU REPREZINTA UN CICLU EULERIAN AL GRAFULUI CITIT"<<endl;
  269. }
  270. break;
  271. case 18:
  272. SetConsoleTextAttribute(hConsole, 5);
  273. G1.afis_grade();
  274. break;
  275. case 19:
  276. SetConsoleTextAttribute(hConsole, 9);
  277. G1.mark_zero();
  278. G1.copiere();
  279. G1.generare_matrice_drumuri();
  280. G1.afisare_matrice_drumuri();
  281. break;
  282. case 20:
  283. SetConsoleTextAttribute(hConsole, 12);
  284. cin>>x>>y;
  285. G1.lant_minim(x,y);
  286.  
  287. default:
  288. comanda_gresita();
  289.  
  290. }
  291. }
  292.  
  293. }
  294. }
  295.  
  296. int main()
  297. {
  298. menu();
  299. return 0;
  300. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement