Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <stdlib.h>
  4. #include <cstring>
  5. #include <conio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. //#include "f1.h"
  9. #include <stdio.h>
  10.  
  11. int n=0;
  12. struct spisoc
  13. {
  14. struct spisoc *next=NULL;
  15. int el=0;
  16. struct stek *stc;
  17. };
  18.  
  19. struct stek
  20. {
  21. struct stek *nex=NULL;
  22. struct stek *back=NULL;
  23. int el=0;
  24. };
  25. struct spisoc *firt=NULL;// (struct spisoc*)malloc(sizeof( struct spisoc)); óêàçàòåëü íà íà÷àëî
  26. struct spisoc *rab=NULL;
  27. struct spisoc *pos=NULL;// óêàçàòåëü íà ïîñëåäíèé
  28. struct spisoc *tn=firt;
  29. struct spisoc *tr=firt;
  30. struct stek *fin=NULL;
  31. struct stek *se=NULL;
  32. struct stek *fr= NULL;//(struct stek*)malloc(sizeof( struct stek));
  33. struct stek *rb= NULL;
  34. int flag_s=0;
  35. int flag_d=0;
  36.  
  37.  
  38.  
  39. using namespace std;
  40.  
  41. int dostup()
  42. {
  43. int a=0,b=0,c;
  44. char c1[]="1234";
  45. char c11[]="max";
  46. char c2[4],c3[3];
  47. printf("vvedire loginl: ");
  48. scanf("%3c3",&c3);
  49. b=strcmp(c11,c3);
  50. if(b!=0)
  51. {
  52. printf("nepravelni login !%s!%s!\n",c2,c3);
  53. }
  54. printf("vvedire porol: ");
  55. scanf("%s",&c2);
  56.  
  57. printf("\n");
  58. system("cls");
  59.  
  60.  
  61. a=strcmp(c1,c2);
  62. if(a!=0)
  63. {
  64. printf("nepravelni porol\n");
  65. }
  66. getch();
  67. system("cls");
  68. while((a!=0)||(b!=0))
  69. {
  70. printf("vvedire ecpe raz\n");
  71. printf("vvedire loginl: ");
  72. scanf("%s",&c3);
  73. b=strcmp(c11,c3);
  74. if(b!=0)
  75. {
  76. printf("nepravelni login\n");
  77. }
  78. printf("vvedire porol: ");
  79. scanf("%s",&c2);
  80. printf("\n");
  81. system("cls");
  82.  
  83. a=strcmp(c1,c2);
  84. if(a!=0)
  85. {
  86. printf("nepravelni porol\n");
  87. }
  88. }
  89.  
  90.  
  91. return a;
  92. }
  93.  
  94. void stekvnul (void);
  95. void proverkanul (void);
  96. void pokazvershni (void);
  97. void deletveshin (void);
  98. void vzitel (void);
  99. void izmenvwrshin (void);
  100. void dobavit (void);
  101. void raspechat (void);
  102.  
  103. void spisvnul (void);
  104. void provenanul (void);
  105. void printstart (void);
  106. void printfinish (void);
  107. void deletstart (void);
  108. void deletefinesh (void);
  109. void vzytstart (void);
  110. void vzytfin (void);
  111. int izmenstart (void);
  112. int izmenfin (void);
  113. void givenstart (void);
  114. void givenfin (void);
  115. void printst (void);
  116.  
  117.  
  118.  
  119.  
  120. int main(int argc, char** argv) {
  121. int flag=0,a=0,b, fff = 0, fff2 = 0;
  122. // flag = dostup();
  123.  
  124. while(flag==0)
  125. {
  126. /*
  127. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  128. printf("%c1 nachat rabotu co ctekom %c\n",178,178);
  129. printf("%c2 nachat raboru co srocami %c\n",178,178);
  130. printf("%c0 zaconcht rabotu %c\n",178,178);
  131. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  132. printf("vvedite ¹ comandi:");
  133. scanf("%d",&a);
  134. system("cls");*/
  135. a=2;
  136. if(a==1){
  137. while(flag==0)
  138. {
  139. z:
  140. system("cls");
  141. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  142. printf("%c1 nachat rabotu co stekom %c\n",178,178);
  143. printf("%c2 sdelat stek pustim %c\n",178,178);
  144. printf("%c3 proverka stek pust/ ne pust %c\n",178,178);
  145. printf("%c4 pokazat vershini stek %c\n",178,178);
  146. printf("%c5 ydalit vershini stek %c\n",178,178);
  147. printf("%c6 vzit element vershini steka %c\n",178,178);
  148. printf("%c7 izminit znacheniy vershini steka %c\n",178,178);
  149. printf("%c8 dobavit element v stek %c\n",178,178);
  150. printf("%c9 raspechatat stuct danih %c\n",178,178);
  151. printf("%c10 zaconcht rabotu %c\n",178,178);
  152. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  153.  
  154. printf("vvedite comandi:");
  155. scanf("%d",&a);
  156. system("cls");
  157.  
  158. switch ( a) {
  159. case 1:
  160. printf ("Vi nachali rabotu\n");
  161. getch();
  162. fff = 1;
  163. break;
  164. case 2:
  165. if (fff==1)
  166. stekvnul();
  167. else
  168. printf ("Vi ne nachali rabotu\n");
  169. getch();
  170.  
  171. break;
  172.  
  173. case 3:
  174. if (fff==1)
  175. proverkanul();
  176. else
  177. printf ("Vi ne nachali rabotu\n");
  178. getch();
  179.  
  180. break;
  181.  
  182. case 4:
  183. if (fff==1)
  184. {pokazvershni();
  185. goto a;}
  186. else
  187. printf ("Vi ne nachali rabotu\n");
  188. getch();
  189.  
  190. break;
  191.  
  192. case 5:
  193. if (fff==1)
  194. {
  195. deletveshin();
  196. goto a;}
  197. else
  198. printf ("Vi ne nachali rabotu\n");
  199. getch();
  200.  
  201. break;
  202.  
  203. case 6:
  204. if (fff==1)
  205. {
  206. vzitel();
  207. goto a;
  208. }
  209. else
  210. printf ("Vi ne nachali rabotu\n");
  211. getch();
  212.  
  213. break;
  214.  
  215. case 7:
  216. if (fff==1)
  217. {
  218. izmenvwrshin();
  219. goto a;
  220. }
  221. else
  222. printf ("Vi ne nachali rabotu\n");
  223. getch();
  224.  
  225. break;
  226.  
  227. case 8:
  228. if (fff==1)
  229. {
  230. if (flag_s>4)
  231. printf("Slishkom mnogo elementov\n");
  232. else
  233. {
  234. dobavit();
  235. goto a;
  236. }
  237. }
  238. else
  239. printf ("Vi ne nachali rabotu\n");
  240. getch();
  241.  
  242. break;
  243.  
  244. case 9:
  245. if (fff==1)
  246. {
  247. a:
  248. raspechat();
  249. getch();
  250. system("cls");
  251. }
  252. else
  253. printf ("Vi ne nachali rabotu\n");
  254. getch();
  255.  
  256. break;
  257.  
  258. case 10:
  259. flag=1;
  260.  
  261. break;
  262.  
  263. default:
  264. break;
  265. }
  266. }
  267. }
  268.  
  269. if(a==2){
  270. while(flag==0)
  271. {
  272. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  273. printf("%c1 nachat rabotu s decom %c\n",178,178);
  274. printf("%c2 sdelat dec pustim %c\n",178,178);
  275. printf("%c3 proverka stek pust/ ne pust %c\n",178,178);
  276. printf("%c4 pokazat znachenie eleenta vnachelt %c\n",178,178);
  277. printf("%c5 pokazat znachenie eleenta v konce %c\n",178,178);
  278. printf("%c6 ydalit eleent v nachale %c\n",178,178);
  279. printf("%c7 ydalit eleent v konce %c\n",178,178);
  280. printf("%c8 vzitie eleenta 1 %c\n",178,178);
  281. printf("%c9 vzitie eleenta n-go %c\n",178,178);
  282. printf("%c10 izminit eleenta 1 %c\n",178,178);
  283. printf("%c11 izminit eleenta n-go %c\n",178,178);
  284. printf("%c12 dobavit eleenta v start %c\n",178,178);
  285. printf("%c13 dobavit eleenta v finishe %c\n",178,178);
  286. printf("%c14 raspechatat stuct danih %c\n",178,178);
  287. printf("%c15 zaconcht rabotu %c\n",178,178);
  288. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  289. printst ();
  290. printf("vvedite comandi:");
  291.  
  292. scanf("%d",&a);
  293. system("cls");
  294. int fg;
  295. switch ( a) {
  296. case 1:
  297. fff2 = 1;
  298. printf ("Vi nachali rabotu\n");
  299.  
  300. case 2:
  301. if (fff2 == 1)
  302. spisvnul ();
  303. else
  304. printf ("Vi ne nachali rabotu\n");
  305. getch();
  306. break;
  307.  
  308. case 3:
  309. if (fff2 == 1)
  310. provenanul ();
  311. else
  312. printf ("Vi ne nachali rabotu\n");
  313. getch();
  314.  
  315. break;
  316.  
  317. case 4:
  318. if (fff2 == 1)
  319. printstart ();
  320. else
  321. printf ("Vi ne nachali rabotu\n");
  322. getch();
  323.  
  324. break;
  325.  
  326. case 5:
  327. if (fff2 == 1)
  328. printfinish ();
  329. else
  330. printf ("Vi ne nachali rabotu\n");
  331. getch();
  332.  
  333. break;
  334.  
  335. case 6:
  336. if (fff2 == 1)
  337. deletstart ();
  338. else
  339. printf ("Vi ne nachali rabotu\n");
  340. getch();
  341.  
  342. break;
  343.  
  344. case 7:
  345. if (fff2 == 1)
  346. deletefinesh ();
  347. else
  348. printf ("Vi ne nachali rabotu\n");
  349. getch();
  350.  
  351. break;
  352.  
  353. case 8:
  354. if (fff2 == 1)
  355. vzytstart ();
  356. else
  357. printf ("Vi ne nachali rabotu\n");
  358. getch();
  359.  
  360. break;
  361.  
  362. case 9:
  363. if (fff2 == 1)
  364. vzytfin ();
  365. else
  366. printf ("Vi ne nachali rabotu\n");
  367. getch();
  368.  
  369. break;
  370.  
  371. case 10:
  372. if (fff2 == 1)
  373. //{
  374. {//deletstart ();
  375. //givenstart ();
  376.  
  377. fg=izmenstart ();
  378. if(fg==1){
  379. goto z;}
  380. }
  381. else
  382. printf ("Vi ne nachali rabotu\n");
  383. getch();
  384.  
  385.  
  386. break;
  387.  
  388. case 11:
  389. if (fff2 == 1)
  390. //{
  391. {
  392. fg=izmenfin ();
  393. if(fg==1){
  394. // deletefinesh();
  395. //givenfin();
  396. goto z;}
  397. }
  398. else
  399. printf ("Vi ne nachali rabotu\n");
  400. getch();
  401.  
  402. break;
  403.  
  404. case 12:
  405. if (fff2 == 1)
  406. {
  407. if(flag_d>4)
  408. printf ("Slishkom mnogo elementov\n");
  409. else{
  410. givenstart ();
  411. goto z;
  412. }
  413. }
  414. else
  415. printf ("Vi ne nachali rabotu\n");
  416. getch();
  417.  
  418. break;
  419.  
  420. case 13:
  421. if (fff2 == 1)
  422. {
  423. if (flag_d>4)
  424. printf ("Slishkom mnogo elementov\n");
  425. else
  426. {givenfin ();goto z;}
  427. }
  428. else
  429. printf ("Vi ne nachali rabotu\n");
  430. getch();
  431.  
  432. break;
  433.  
  434. case 14:
  435. if (fff2 == 1)
  436. printst ();
  437. else
  438. printf ("Vi ne nachali rabotu\n");
  439. getch();
  440.  
  441. break;
  442.  
  443. case 15:
  444. {flag=1;
  445. system("cls");
  446. exit(0);
  447. }
  448. break;
  449.  
  450. default:
  451. break;
  452. }
  453. }}
  454.  
  455. if(a!=0)
  456. {
  457. flag=0;
  458. }
  459. else
  460. {
  461. flag=1;
  462. }
  463.  
  464. }
  465.  
  466.  
  467. return 0;
  468. }
  469. // stek/////////////////////////////////////////////////////////////////////
  470.  
  471. void stekvnul(void)
  472. {
  473. rb=NULL;
  474. printf("SRABOTALO\nstrukt delete\n");
  475. flag_s = 0;
  476. getch();
  477. system("cls");
  478. }
  479.  
  480. void proverkanul (void)
  481. {
  482. if(rb==NULL)
  483. {
  484. printf("stek PUST");
  485. }
  486. else
  487. {
  488. printf("stek NE PUST");
  489. }
  490. getch();
  491. system("cls");
  492.  
  493. }
  494.  
  495. void pokazvershni (void)
  496. {
  497. if (rb!=NULL)
  498. {
  499. printf("vershina steca: >%d< = %d %d %d\n",rb->el,rb->back,rb,rb->nex);
  500. }
  501. else
  502. printf ("stek pust\n");
  503. getch();
  504. system("cls");
  505. }
  506.  
  507. void deletveshin (void)
  508. {
  509. if (rb!=NULL)
  510. {
  511. fin=rb->back;
  512. rb=rb->back;
  513. rb->nex=NULL;
  514. printf("delete OK");
  515. }
  516. else
  517. printf ("stek pust\n");
  518. if (flag_s>=0)
  519. flag_s--;
  520.  
  521. getch();
  522. system("cls");
  523.  
  524. }
  525. void vzitel (void)
  526. {
  527. if (rb!=NULL)
  528. {
  529. printf("bil vzyt eement: >%d< = %d %d %d\n",rb->el,rb->back,rb,rb->nex);
  530. fin=rb->back;
  531. rb=rb->back;
  532. rb->nex=NULL;
  533. printf("delete OK");
  534. }
  535. else
  536. printf ("stek pust\n");
  537. if (flag_s>=0)
  538. flag_s--;
  539.  
  540. getch();
  541. system("cls");
  542. }
  543. void izmenvwrshin (void)
  544. {
  545. int b;
  546. if (rb!=NULL)
  547. {
  548. printf("vvedite chislo: ");
  549. scanf("%d",&b);
  550. rb->el=b;
  551. }
  552. else
  553. printf ("stek pust\n");
  554.  
  555. getch();
  556. system("cls");
  557. }
  558. void dobavit (void)
  559. {
  560. int b,t=0;
  561. printf("vvedite chislo: ");
  562. scanf("%d",&b);
  563. if(rb==NULL)
  564. {
  565. printf("SRABOTALO\n");
  566. rb=( stek*)malloc(sizeof( struct stek));
  567.  
  568. rb->back=NULL;
  569. rb->el=b;
  570. rb->nex=NULL;
  571. fin=rb;
  572. printf("%d = %d %d %d\n",rb->el,rb->back,rb,rb->nex);
  573. t=1;
  574. }
  575. if((rb!=NULL)&&(t==0))
  576. {
  577. rb->nex = ( stek*)malloc(sizeof( struct stek));
  578. se=rb;
  579. rb=rb->nex;
  580. rb->back=se;
  581. rb->el=b;
  582. rb->nex=NULL;
  583. fin=rb;
  584. printf("%d = %d %d %d\n",rb->el,rb->back,rb,rb->nex);
  585. }
  586. // fin=rb;
  587. tn->stc=rb;
  588. flag_s++;
  589.  
  590. getch();
  591. system("cls");
  592. }
  593.  
  594. void raspechat (void)
  595. { int flag=0;;
  596. //fin=rb;
  597. tn->stc=rb;
  598. printf("znachenie steca: ");
  599. while (rb!=NULL)
  600. {
  601. if(flag==0){
  602. printf(">");
  603. }
  604. printf("%d ",rb->el);
  605. if(flag==0){
  606. printf("<");
  607. flag=1;
  608. }
  609. // printf("= %d %d %d\n",rb->back,rb,rb->nex);
  610. rb=rb->back;
  611. }
  612. rb=tn->stc;
  613. printf ("bolshe nechego pechatat");
  614. }
  615. // dec///////////////////////////////////////////////////////////////////////////
  616.  
  617.  
  618.  
  619. void spisvnul (void) //2
  620. {
  621. printf("structura dec delete\n");
  622. tn=NULL;
  623. rab=NULL;
  624. firt=NULL;
  625. printf("structura dec delete\n");
  626. getch();
  627. flag_d = 0;
  628. flag_s = 0;
  629. system("cls");
  630. n=0;
  631. }
  632. void provenanul (void) //3
  633. {
  634. rab=firt;
  635. if(rab==NULL)
  636. {
  637. printf("dec PUST");
  638. }
  639. else
  640. {
  641. printf("dec NE PUST");
  642. }
  643. getch();
  644. system("cls");
  645. }
  646.  
  647.  
  648. void printstart (void) //4
  649. {
  650.  
  651.  
  652. if(firt!=NULL)
  653. {
  654. printf("element v nachale deca: %d\n",firt);
  655. rb=firt->stc;
  656. while(rb!=NULL)
  657. {
  658. printf ("stek: %d\n",rb->el);
  659. rb=rb->back;
  660. }
  661. printst();
  662. }
  663. else
  664. {
  665. printf ("y nas net elementov");
  666. }
  667.  
  668. // printst();
  669. getch();
  670. system("cls");
  671. }
  672. void printfinish (void) //5
  673. {
  674. if(pos!=NULL)
  675. {
  676. printf("element v konce deca: %d\n",pos);
  677. rb=pos->stc;
  678. while(rb!=NULL)
  679. {
  680. printf ("stek: %d\n",rb->el);
  681. rb=rb->back;
  682. }
  683. printst();
  684. }
  685. else
  686. {
  687. printf ("y nas net elementov");
  688. }
  689. getch();
  690. system("cls");
  691. }
  692. void deletstart (void) //6
  693. {
  694. if(firt!=NULL)
  695. {
  696. firt=firt->next;
  697. printf("delete OK");
  698. //raspechat();
  699. printst();
  700. }
  701. else
  702. { printf("struct ne suchestvuet \n");
  703. printf("delete ne OK\n");
  704. }
  705. if (flag_d>=0)
  706. flag_d--;
  707. flag_s = 0;
  708. getch();
  709. system("cls");
  710. }
  711. void deletefinesh (void) //7
  712. {
  713. if(firt!=NULL)
  714. {
  715. rab=firt;
  716. while(rab!=NULL)
  717. {
  718. if(rab->next==pos)
  719. {
  720. pos=rab;
  721. pos->next=NULL;
  722. }
  723. rab=rab->next;
  724. }
  725. printf("delete OK");
  726. //raspechat();
  727. printst();
  728. }
  729. else
  730. { printf("struct ne suchestvuet\n");
  731. printf("delete ne OK\n");
  732. }
  733. if (flag_d>=0)
  734. flag_d--;
  735. flag_s = 0;
  736. getch();
  737. system("cls");
  738. }
  739. void vzytstart (void) //8
  740. {
  741. printstart();
  742. deletstart();
  743.  
  744. }
  745. void vzytfin (void) //9
  746. {
  747. printfinish();
  748. deletefinesh();
  749. }
  750. int izmenstart () //10
  751. {
  752. if(firt!=NULL){
  753. rb=firt->stc;
  754.  
  755. //deletstart();
  756. //givenstart();
  757. getch();
  758. system("cls");
  759. return 1;
  760.  
  761. }
  762. else
  763. {printf(" y nac net strectur nam ne c chem rabotat");
  764. getch();
  765. system("cls");
  766. return 0;
  767. }
  768.  
  769.  
  770. }
  771. int izmenfin () //11
  772. {
  773. if(firt!=NULL){
  774. rb=pos->stc;
  775.  
  776. //deletefinesh();
  777. //givenfin();
  778. getch();
  779. system("cls");
  780. return 1;
  781. }
  782. else
  783. {printf(" y nac net strectur nam ne c chem rabotat");
  784. getch();
  785. system("cls");
  786. return 0;
  787. }
  788.  
  789. }
  790. void givenstart (void) //12
  791. {
  792. if(firt==NULL)
  793. {
  794. printf("1 zashlo\n");
  795. firt=(struct spisoc*)malloc(sizeof( struct spisoc));
  796. printf("1 zashlo\n");
  797. pos=firt;
  798. printf("1 zashlo\n");
  799. firt->next=NULL;
  800. printf("1 zashlo\n");
  801. pos->next=NULL;
  802. printf("1 zashlo\n");
  803. rab=firt;
  804. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  805. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  806. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  807.  
  808. tn=firt;
  809.  
  810. }
  811. else
  812. {
  813. rab=firt;
  814. printf("2 zashlo\n");
  815. firt=(struct spisoc*)malloc(sizeof( struct spisoc));
  816. firt->next=rab;
  817.  
  818. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  819. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  820. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  821. tn=firt;
  822. }
  823.  
  824. printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  825. tn->stc=( stek*)malloc(sizeof( struct stek));
  826. stekvnul();
  827. /*
  828. if(firt->next==NULL)
  829. {
  830.  
  831. firt->stc=( stek*)malloc(sizeof( struct stek));
  832. stekvnul();
  833. }
  834. if(firt->next!=NULL)
  835. {
  836. rab=firt->next;
  837. rab->stc=( stek*)malloc(sizeof( struct stek));
  838. stekvnul();
  839. }*/
  840. flag_d++;
  841. flag_s = 0;
  842.  
  843. printf("NOW sozdan\n");
  844. getch();
  845. system("cls");
  846. }
  847. void givenfin (void) //13
  848. {
  849. if(firt==NULL)
  850. {
  851. printf("1 zashlo\n");
  852. firt=(struct spisoc*)malloc(sizeof( struct spisoc));
  853. pos=firt;
  854. firt->next=NULL;
  855. pos->next=NULL;
  856. rab=firt;
  857. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  858. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  859. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  860.  
  861. tn=pos;
  862.  
  863.  
  864. }
  865. else
  866. {
  867. if(firt->next==NULL)
  868. {
  869. rab=firt;
  870. printf("2 zashlo\n");
  871. pos->next=(struct spisoc*)malloc(sizeof( struct spisoc));
  872. firt->next=pos->next;
  873. rab=pos;
  874. pos=pos->next;
  875. pos->next=NULL;
  876. printf("rab = %d %d %d\n",rab,rab->next,rab->stc);
  877. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  878. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  879. tn=pos;
  880. }
  881. else
  882. {
  883. printf("3 zashlo\n");
  884. pos->next=(struct spisoc*)malloc(sizeof( struct spisoc));
  885. rab=pos;
  886. pos=pos->next;
  887. pos->next=NULL;
  888. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  889. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  890. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  891. tn=pos;
  892. }
  893.  
  894. }
  895. printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  896. tn->stc=( stek*)malloc(sizeof( struct stek));
  897. stekvnul();
  898.  
  899. flag_d++;
  900. flag_s = 0;
  901. printf("NOW sozdan\n");
  902. getch();
  903. system("cls");
  904. }
  905.  
  906. void printst (void) //14
  907. {
  908.  
  909. tn=firt;
  910. if(tn==NULL)
  911. printf("PUSTO\n");
  912. else
  913. printf("OK\n");
  914. while(tn!=NULL)
  915. {
  916. printf("DEC:\n");
  917. printf ("----------------\n");
  918. rb=tn->stc;
  919. while(rb!=NULL)
  920. {
  921. printf ("stek: %d\n",rb->el);
  922. rb=rb->back;
  923. }
  924.  
  925. tn=tn->next;
  926.  
  927. }
  928.  
  929. //getch();
  930. // system("cls");
  931. }
  932.  
  933. /*void printzaukaz (void) //7
  934. {
  935. if(tn->next!=NULL)
  936. {
  937. rab=tn->next;
  938. rb=rab->stc;
  939. printf("element za rabochim ucazatelem: %d %d %d\n",rab,rab->stc,rab->next);
  940. raspechat();
  941. }
  942. else
  943. {
  944. printf ("ucazatel v konce spica");
  945.  
  946. }
  947.  
  948.  
  949. getch();
  950. system("cls");
  951. }
  952. void deletezaukaz (void) //8
  953. {
  954. if(tn->next!=NULL)
  955. {
  956. rab=tn;
  957. rab=rab->next;
  958. tn->next=rab->next;
  959. rb=rab->stc;
  960. //printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  961. printf("delete OK");
  962. //raspechat();
  963. }
  964. else
  965. { printf("nash ukazatel naxoditsa v konse(rekomenduetsa ego peredvinut)\n");
  966. printf("delete ne OK\n");
  967. }
  968.  
  969. getch();
  970. system("cls");
  971. }
  972. void vzytzaukaz (void) //9
  973. {
  974. if(tn->next!=NULL)
  975. {
  976. rab=tn;
  977. rab=rab->next;
  978. rb=rab->stc;
  979. printf("vzytiy element za rabochim ucazatelem: >%d< %d %d",rab,rab->stc,rab->next);
  980. raspechat();
  981. tn->next=rab->next;
  982. printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  983. }
  984. else
  985. { printf("nash ukazatel naxoditsa v konse(rekomenduetsa ego peredvinut)");
  986. }
  987. getch();
  988. system("cls");
  989. }
  990. void izmenzaukaz (void) //10
  991. {
  992. if(tn->next!=NULL)
  993. {
  994. rab=tn->next;
  995. rab->stc=( stek*)malloc(sizeof( struct stek));
  996. //stekvnul();
  997. }
  998. else
  999. {printf("nash ukazatel naxoditsa v konse(rekomenduetsa ego peredvinut)\n");
  1000. }
  1001. }
  1002. void givenzaukaz (void) //11
  1003. {
  1004. int o=1;
  1005. if(n==0&&rab==NULL)
  1006. {
  1007. n++;o=0;
  1008. printf("1 zashlo\n");
  1009. firt=(struct spisoc*)malloc(sizeof( struct spisoc));
  1010. rab=firt;
  1011. firt->next=rab;
  1012. rab->next=NULL;
  1013. tn=rab;
  1014. rab->el=n;
  1015. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  1016. printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  1017. printf("firt=%d %d %d\n",firt,firt->next,firt->stc);
  1018.  
  1019. }
  1020. if((tn!=NULL)&&(tn->next==NULL)&&(o==1))
  1021. {
  1022. printf("2 zashlo\n");
  1023. rab=tn;
  1024. rab->next=(struct spisoc*)malloc(sizeof( struct spisoc));
  1025. rab=rab->next;
  1026. rab->next=NULL;
  1027. tn->next=rab;
  1028. printf("firt=%d %d %d\n",firt,firt->next,firt->stc);
  1029. printf("rab=%d %d %d\n",rab,rab->next,rab->stc);
  1030. printf("tn=%d %d %d\n",tn,tn->next,tn->stc);
  1031. n++;
  1032. rab->el=n;
  1033. o=0;
  1034. }
  1035. if((tn!=NULL)&&(tn->next!=NULL)&&(o==1))
  1036. {
  1037. printf("3 zashlo\n");
  1038.  
  1039.  
  1040. printf("tn=%d %d %d\n",tn,tn->next,tn->stc);
  1041. tr=(struct spisoc*)malloc(sizeof( struct spisoc));
  1042. printf("tr=%d %d %d\n",tr,tr->next,tr->stc);
  1043. rab=tn;
  1044. rab=rab->next;
  1045. printf("rab=%d %d %d\n",rab,rab->next,rab->stc);
  1046. tr->next=rab;
  1047. printf("tr=%d %d %d\n",tr,tr->next,tr->stc);
  1048. tn->next=tr;
  1049. printf("tn=%d %d %d\n",tn,tn->next,tn->stc);
  1050. //tr->stc=NULL;
  1051. rab=tr;
  1052.  
  1053. }
  1054.  
  1055. //tn->stc=NULL;
  1056. //rab->stc=NULL;
  1057. if(tn->next==NULL)
  1058. {
  1059.  
  1060. rab->stc=( stek*)malloc(sizeof( struct stek));
  1061. stekvnul();
  1062. }
  1063. if(tn->next!=NULL)
  1064. {
  1065. tn=tn->next;
  1066. rab->stc=( stek*)malloc(sizeof( struct stek));
  1067. stekvnul();
  1068. }
  1069.  
  1070.  
  1071. printf("NOW sozdan\n");
  1072. getch();
  1073. system("cls");
  1074. }
  1075. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement